<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=postbody>I've searched the boards for a while and seen a few
posts alluding to the same issue but never a conclusive answer. <BR><BR>The
application - swing rich client on a single user local db. <BR><BR>In this
situation I think a session-per-application is desirable. If I load an entity,
say the contact "Tom Hughes", I want only one object instance for that entity at
any one time. Therefore if edit 'Tom Hughes" on my search screen, it is updated
on my "Favourites Contacts" screen because it is the same object instance.
Having a shared instance avoids me having stale data on my application's forms
and avoids me having to listen to update events (via the interceptor or event
mechanism or other means) and reload my forms as needed - this has a negative
impact on performance, robustness and complexity. <BR>I do realise the power of
sessions and how they are used, please don't point me to here : <A
href="http://hibernate.org/42.html#A11"
target=_blank>http://hibernate.org/42.html#A11</A> <BR>I think though in my
single useer db, I don't care about multiple sessions. They only serve to
complicate. <BR><BR>Unfortunately I don't think I can implement a
session-per-application because of the behaviour of the first level 'cache', ie.
the session. That is, entities loaded into the session stay there until the
session is closed. <BR><BR>I was thinking it may be possible to write a session
that used weak references for all non-dirty entities. Entities could then be
garbage collected when my app no longer needed them. I would be willing to
contribute this work if feasible. <BR><BR>So the questions, <BR>* I'm not a
hibernate expert so are there any flaws in my reasoning? </SPAN></DIV>
<DIV><SPAN class=postbody><SPAN class=399384623-24092006></SPAN><FONT
face=Arial><FONT size=2>*<SPAN class=399384623-24092006> Should I be using
hibernate this way in a two teir architecture?</SPAN></FONT></FONT><BR>* Is
there an existing method to manage the first level cache? <BR>* Is the
suggestion of a weakly referenced session implementation feasible? <BR><BR>This
would be super, super useful and from my research, I'm not the only one having
these problems. <BR><BR>thanks, <BR>Tom Hughes</SPAN></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>