We're updating the issue view to help you get more done. 

relation not flushed when collection created after persist with enhanced entities

Description

When a collection is only created after the owning entity has been persisted, a change to that collection is not made persistent.
The attached test case (run with "mvn test") produces:

1 2 3 4 5 6 7 2016-07-22 23:15:30,183 DEBUG org.hibernate.SQL - insert into Thing (id) values (null) 2016-07-22 23:15:30,201 DEBUG org.hibernate.SQL - insert into SomeEntity (id) values (null) 2016-07-22 23:15:30,220 DEBUG org.hibernate.SQL - select someentity0_.id as id1_0_0_ from SomeEntity someentity0_ where someentity0_.id=? 2016-07-22 23:15:30,252 DEBUG org.hibernate.SQL - select things0_.SomeEntity_id as SomeEnti1_1_0_, things0_.things_id as things_i2_1_0_, thing1_.id as id1_2_1_ from SomeEntity_Thing things0_ inner join Thing thing1_ on things0_.things_id=thing1_.id where things0_.SomeEntity_id=? Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.748 sec <<< FAILURE! test(eu.pinske.test.ThingTest) Time elapsed: 2.65 sec <<< FAILURE! java.lang.AssertionError: relation not persisted expected:<1> but was:<0>

When run without enhancement or when the collection is created before flush (see comment in unit test), the test produces the expected outcome.

I don't know, if this was ever supported, or whether we just relied on unsupported behaviour until now. Would you please take a look?

Environment

None

Status

Assignee

Luis Barreiro

Reporter

Alexander Pinske

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

5.2.1

Priority

Major