Issue Details (XML | Word | Printable)

Key: HHH-3782
Type: Bug Bug
Status: Resolved Resolved
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: Adam Warski
Reporter: Daniel Meyer
Votes: 0
Watchers: 1
Operations

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

Saving a one-to-many relationship results in unsaved transient instance exception

Created: 24/Feb/09 04:07 PM   Updated: 02/Mar/09 01:05 PM   Resolved: 02/Mar/09 01:05 PM
Component/s: envers
Affects Version/s: 3.3.1
Fix Version/s: 3.5.0.Beta-1

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive envers-with-collections.zip (15 kB)

Environment:
Hibernate 3.3.1.GA
Oracle XE 10g

Bug Testcase Reminder (view):
REMINDER: Bug reports should generally be accompanied by a test case
Participants: Adam Warski and Daniel Meyer


 Description  « Hide

When I create a transient set and a transient item, point them to each other, and then commit the set-with-the-item-in-it, I get this exception: "org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing"

This does not happen when I'm not using envers.

The attached project's testComplexCreate() method demonstrates the error. To run the tests, execute "mvn clean install" (requires Apache Maven, I use version 2.0.9); then target/surefire-reports/com.example.db.EnversWithCollectionsTest.txt will have the stack trace.



Daniel Meyer added a comment - 25/Feb/09 08:16 AM

I should also point out the testSimpleCreate() method in the EnversWithCollectionsTest class - it commits the empty set first, retrieves it from the database, then saves the item (the greeting). This works; it's the cascading save (demonstrated by testComplexCreate()) that results in the error.


Adam Warski added a comment - 02/Mar/09 01:05 PM

I tried and that's true that I get the error, but I get it regardless if I switch Envers on or off.

What you are missing, is the cascade on GreetingPO.getGreetingSet: the annotation there should be for example @ManyToOne(cascade = CascadeType.ALL).

With the cascade turned on, the test passes with and without Envers.