Does beginTransaction in Hibernate allocate a new DB connection?
Posted
by illscience
on Stack Overflow
See other posts from Stack Overflow
or by illscience
Published on 2010-03-29T18:18:40Z
Indexed on
2010/03/29
18:23 UTC
Read the original article
Hit count: 145
Hi folks - Just wondering if beginning a new transaction in Hibernate actually allocates a connection to the DB?
I'm concerned b/c our server begins a new transaction for each request received, even if that request doesn't interact with the DB. We're seeing DB connections as a major bottleneck, so I'm wondering if I should take the time narrow the scope of my transactions.
Searched everywhere and haven't been able to find a good answer. The very simple code is here:
SessionFactory sessionFactory = (SessionFactory) Context.getContext().getBean("sessionFactory");
sessionFactory.getCurrentSession().beginTransaction();
sessionFactory.getCurrentSession().setFlushMode(FlushMode.AUTO);
thanks very much! a
© Stack Overflow or respective owner