-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Transaction and Hibernate.initialize()
PostPosted: Sat Jul 03, 2004 5:38 pm 
Newbie

Joined: Wed Jun 09, 2004 12:19 am
Posts: 4
Do I need to place Hibernate.initialize() inside a transaction context? When I first asked myself, I thought it is a sure thing. The call needs to be place inside a transaction:


tx = session.beginTransaction();
session.lock(user, LockMode.NONE);
Hibernate.initialize(user.getSites());
tx.commit();
}catch (HibernateException e) {
if ( tx != null ) {
try {
tx.rollback();
} catch (HibernateException he) {
.......
}

}finally {
if (session!= null) {
try {
session.close();
} catch (HibernateException e) {
....
}
}
}


But everytime, I am getting a warning message as below,

WARN [net.sf.hibernate.impl.SessionImpl] - -
afterTransactionCompletion() was never called

If I remove the transaction and call Hibernate.initialize() directly. The WARN message never shows up. So I assume there is no need to initialize under a transaction context. Am I correct? If not, what do I need to do to make the warning message go away? I am a little bothered by that...

Thanks.
AW


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 03, 2004 6:00 pm 
Senior
Senior

Joined: Sun Jan 04, 2004 2:46 pm
Posts: 147
This warning appears if the session detects the transaction has not terminated properly when it is garbage collected ( finalize method ). Check your transaction logic again to make sure either commit() or rollback() is called every time.

It's also possible that it is not this session causing the problem but another if there are others being opened in the same process. The garbage collection only runs when it feels like it so the finalize method containing this warning can run as soon as a session goes out of scope or several minutes later.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 04, 2004 10:39 am 
Newbie

Joined: Wed Jun 09, 2004 12:19 am
Posts: 4
Hmm... The transaction logic is the same as when I use session.get(), session.find(), session.createQuery(), etc. The WARN message only appears when I use session.lock(); Hibernate.initialize().

If it is caused by other sessions, should I worry about it?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.