Changes are not properly rollbacked after a bulk operation involving classes that use joined-subclass mapping

Description

I have a Location class on which two other classes "depend" (Contact and LocationTransaction).
When I want to delete a Location Object I use bulk update operations. First I delete the LocationTransactions
connected to the Location object and then I delete the contact objects connected to the location object. Finally
I delete the Location object itself. At the end I simulate that something went wrong and trigger a Rollback.
After the rollback I would expect that none of the objects that I tried to delete was actually deleted. However,
all the LocationTransaction objects are missing from the database after the rollback. Since the other objects
are rollbacked properly I figure that the problem is connected to the fact that LocationTransactions is inherited
from Transaction and uses joined-subclass mapping which is included in the test project in the attachment.

private static void doTest() {
final Session s = sf.openSession();
final Transaction tx = s.beginTransaction();
try {
Location l = (Location) s.createQuery("from Location l where l.name = 'l1'").uniqueResult();

final Query deleteTransactionQuery = s.createQuery(
"delete from LocationTransaction lt " +
"where lt.location = (:location)");
deleteTransactionQuery.setParameter("location", l);
deleteTransactionQuery.executeUpdate();

final Query deleteContactQuery = s.createQuery(
"delete from Contact c " +
"where c.location = (:location)");
deleteContactQuery.setParameter("location", l);
deleteContactQuery.executeUpdate();

final Query deleteQuery = s.createQuery(
"delete from Location l where l = (:location)");
deleteQuery.setParameter("location", l);
deleteQuery.executeUpdate();

//s.delete(l);
throw new RuntimeException("test");
//tx.commit();
} catch (Exception e) {
tx.rollback();
System.out.println(e);
} finally {
s.close();
}
}

Please contact me with any further questions.
Thanks for the help.

Environment

Hibernate 3.2.5.ga and 3.3.0.SP1
MySql database version 5.1.36
Driver : mysql-connector-java-5.1.6

Activity

Show:
dilbert
January 21, 2010, 3:38 PM

Confirmed same bug with version 3.3.2.GA of hibernate-core (from maven repo), mysql-connector-java-5.1.9 and MySQL 5.1.42

Brett Meyer
April 7, 2014, 5:48 PM

In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.

If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.

Thank you!

Brett Meyer
July 8, 2014, 3:10 PM

Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!

Rejected

Assignee

Unassigned

Reporter

dilbert

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure