-->
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: Why sould I not use a session-per-application pattern?
PostPosted: Sat Nov 06, 2004 2:50 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Hi

We're trying to integrate Hibernate with the corix 4i Framework (http://www.corix.ch).

4i requires object identity within the live of one JVM process. AFAIK hibernate guarantees object identity only within one session. Thes drives me towards a session-per-application pattern.

Since the wiki entry http://www.hibernate.org/168.html lists this as an anti pattern, I'd like to now what kind of problems I might face.


I already understood the following things:
  1. A session is not thread save. If I need thread savety I can maybe wrap the session with a synchronizing dynamic proxy.
  2. Getting a HibernateException means, that I've to stop the application. Well not perfect, but I think I shouldn't get HibernateExceptions during normal operation.
  3. The session caches every persistent object. This means it grows endlessly. AFAIK Session.clear() isn't an option, since this maybe violates object identity. Would it be possible to patch the session to use weak references for it's cache?


Any ideas are very welcome.
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 06, 2004 5:07 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I don't think Hibernate is the right choice in this environment. It's completely designed around transaction scoped object idendity.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 06, 2004 5:20 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Ok.

I just like to understand the details: Let's assume I find a way to do a Session.clear() every now and then. Are there other problems with the session-per-application pattern?

TIA
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 06, 2004 5:24 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You are right about a), b) and c) being a problem in your situation and I don't think your solutions work perfectly. I've never tried something like this myself, so I can't say for sure

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.