Is there any difference in which order I createCriteria and beginTransaction using Hibernate?

Posted by user2519543 on Stack Overflow See other posts from Stack Overflow or by user2519543
Published on 2013-06-25T10:19:37Z Indexed on 2013/06/25 10:21 UTC
Read the original article Hit count: 194

Filed under:
|
|
|

Just wondering is there any difference when I beginTransaction [org.hibernate] before or after creating Criteria/Query etc.?

example 1:

...
Transaction tx= session.beginTransaction();
Criteria c = session.createCriteria(class);
result = c.uniqueResult();
tx.commit();
...

example 2:

...
Criteria c = session.createCriteria(class);
Transaction tx= session.beginTransaction();
result = c.uniqueResult();
tx.commit();
...

Thanks.

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate