| Author |
Hibernate 3.3.2 not flushing inserts before selects
|
Daniel Matthews
Greenhorn
Joined: Aug 17, 2009
Posts: 7
|
|
Hi,
I am experiencing a strange problem when using Hibernate EntityManager 3.3.2 where insert queries are not flushed to the db before attempting a select query within the same transaction.
I am using container-managed JTA transactions (Weblogic) and Oracle 9i.
This is quite confusing as i have a unit test that exercises this code but it auto flushes prior to executing the select. This is also running in JTA transaction (JOTM) against HSQLDB.
I would appreciate it if any one could clarify what is supposed to happen in this scenario?
|
 |
Emanuel Kadziela
Ranch Hand
Joined: Mar 24, 2005
Posts: 186
|
|
|
Do you get any error message? What does your code look like?
|
 |
Daniel Matthews
Greenhorn
Joined: Aug 17, 2009
Posts: 7
|
|
Hi,
I do not get any error messages as the entity manager is flushed when the transaction commits. In short here is my code
all within a single transaction:
I would have thought that when an Invoice is persisted the subsequent call to findExistingInvoice for the next charge would flush the entity manager as it does in my unit test.
I can work around this problem by changing my transaction boundaries, i.e. each iteration is separate unit of work but i would like to know what hibernate is doing.
|
 |
stanislav bashkirtsev
Ranch Hand
Joined: Aug 17, 2009
Posts: 75
|
|
|
You didn't show the code that saves objects.
|
 |
Eduardo Bueno
Ranch Hand
Joined: Jun 04, 2009
Posts: 154
|
|
|
You could try closing the session instead of flushing.
|
 |
Daniel Matthews
Greenhorn
Joined: Aug 17, 2009
Posts: 7
|
|
This is not really an option the session/entity manager is container managed (or has the semantics of) via Springs orm stuff. Anyhow I have changed my transaction boundaries now to get around this.
Thanks
|
 |
 |
|
|
subject: Hibernate 3.3.2 not flushing inserts before selects
|
|
|