Issue Details (XML | Word | Printable)

Key: HHH-2259
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Steve Ebersole
Reporter: Ulrich Winter
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Hibernate Core

autoflush and autoclose not longer occur in JTA environment with hibernate 3.2

Created: 21/Nov/06 12:19 PM   Updated: 22/Nov/06 06:54 AM   Resolved: 22/Nov/06 06:54 AM
Component/s: core
Affects Version/s: 3.2.0.ga, 3.2.1
Fix Version/s: 3.2.2

Time Tracking:
Not Specified

Environment: jboss 4.0.5

Bug Testcase Reminder (view):
REMINDER: Bug reports should generally be accompanied by a test case
Participants: Steve Ebersole and Ulrich Winter


 Description  « Hide

In a setup using JTASessionContext flush() and close() should occur automatically at the end of the transaction.

This works with hibernate 3.0.5 but does not with hibernate 3.2.0-ga and 3.2.1-ga.

Setup:
hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
hibernate.current_session_context_class=org.hibernate.context.JTASessionContext
hibernate.transaction.flush_before_completion=true
hibernate.transaction.auto_close_session=true

Usage:
public void doSomeWork() throws Exception { TransactionManager tm = (TransactionManager) Locator.lookup("java:/TransactionManager"); tm.begin(); Session session = sf.getCurrentSession(); PersistentObject data = new PersistentObject (); data.setXYZ("xyz"); session.save(data); tm.commit(); }

Symptom:
no inserts/updates/deletes, only "select xxx.nextval()" occur to the database.



Steve Ebersole added a comment - 21/Nov/06 03:10 PM

Do you have a setting for 'hibernate.transaction.factory_class'? If not, Hibernate defaults to using JDBC-based transactions (that has not changed...).


Ulrich Winter added a comment - 22/Nov/06 02:09 AM

No I didn't.
With hibernate 3.0.5 the autoflush was working without that.

[Environment] Hibernate 3.0.5
[TransactionFactoryFactory] Using default transaction strategy (direct JDBC transactions)

After setting that property with hibernate 3.2.0 it also flushes the session in beforeCompletion().
hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory

I thought that setting
hibernate.current_session_context_class=org.hibernate.context.JTASessionContext
was enough to activate JTA behavior, because the javadoc of JTASessionContext says
"Note that the sessions returned from this method are automatically configured with both the auto-flush and auto-close attributes set to true."

But that assumption was probably wrong.
So it's not a bug but a slightly changed behavior in 3.2.0-ga.


Steve Ebersole added a comment - 22/Nov/06 06:19 AM

Ah yes, there was a change to how the transaction synchronization is registered starting with 3.2 for JPA compliance which would cause this. At least it should cause a warning.


Steve Ebersole added a comment - 22/Nov/06 06:54 AM

warning added