As long as both of the sessions are on the same underlying Connection
this should be achievable.  Otherwise you'd run into txn isolation
issues.

Using the current HibernateContext code as an example, we could
implement something like "flush on retrieval".  HibernateContext does
something very similar in its txn Synchronization; on txn completion, it
checks to see if the session is dirty and if so flushes it.  So in the
HibernateContext class, it be as simple as modifying the getSession()
method to flush the session prior to returning it if it was pre-existing
and it is dirty.

But I tend to think it is better to let application code handle these
explicit intermediate flushes.  Obviously it makes sense at txn
completion time.


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Igor
Fedorenko
Sent: Wednesday, September 22, 2004 1:41 PM
To: Bill Burke
Cc: hibernate list
Subject: Re: [Fwd: Re: [Hibernate] Hibernate aspects]

Basically, I need to flush the session if
* I am calling into code that will open another hibernate session. This 
will be the case if I call a remote object, but may happen with local 
invocation too, if for example, target EJB runs under different security

role.
* I am calling into code that uses JDBC to access the same database 
directly. Again, this can be both local and remote invocations.

I know this is tricky ;-)

Bill Burke wrote:
> 
> 
> Igor Fedorenko wrote:
> 
>>
>> What about session flushing? Say I am writing an EJB that writes
>> something to the database through Hibernate and then calls another
>> remote EJB.
>>
> 
> What would be the semantics?  You would also need the ability to 
> associate a Session with a thread as well to get this automatic 
> functionality.
> 
> Bill
> 
> 
> 
> 
> 


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel




-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to