-->
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.  [ 4 posts ] 
Author Message
 Post subject: ThreadLocalSessionContext.CleanupSynch suggestion
PostPosted: Wed Jan 04, 2006 7:49 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
Hello,
I am implementing my own ThreadLocalSessionContext handler and came across an issue.

When you want to implement a new class extending the CleanUpSynch, it is not possible to access the factory. The factory attribute is privat.

I suggest to make the factory attribute protected to have access to it from subclasses.
Please tell me if I am wrong or if I overlooked something.

Best Regards

Sebastian

Hibernate version:
3.1
Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 9:07 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You are supposed to override this:

protected CleanupSynch buildCleanupSynch() {
return new CleanupSynch( factory );
}


And implement your own CleanupSynch class. You are not supposed to override the existing CleanupSynch. See ExtendedThreadLocalSessionContext.java in CaveatEmptor.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 10:26 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
Hello Christian,

in ExtendedThreadLocalSessionContext the NoCleanupSynch in the Caveat Emptor example does extend the CleanUpSynch from the ThreadLocalSessionContext. See the snipped below.
I followed this proposal but wanted to access the factory in the afterCompletion and got the problem I explained.

In my humble opinion this is not pretty clear as example. Either the NoCleanupSynch example should not extend CleanUpSynch or the factory should be protected.

Best Regards and thank you for the feedback

Sebastian

......... snip ...........
protected CleanupSynch buildCleanupSynch() {
return new NoCleanupSynch(factory);
}
private static class NoCleanupSynch extends ThreadLocalSessionContext.CleanupSynch {
public NoCleanupSynch(SessionFactory factory) { super(factory); }
public void beforeCompletion() {}
public void afterCompletion(int i) {}
}

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 11:13 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I've relaxed this in CVS.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.