In some cases evicting a transient entity gives: java.lang.IllegalArgumentException: Non-entity object instance passed to evict
I'm aware of several Hibernate issues covering this, and I'm also aware that some of the eviction rules changed due to JPA2.1 spec. However, the behavior seen here is inconsistent: when using XML mapping files and using the entity-name attribute on the class mapping, this exception seems to appear when the parent of a one-to-many is evicted while one of it's children is not yet persisted. When using the exact same example, but instead not using entity-name (and thus referring to the entity using it's class name) the eviction seems to work without a problem.
Please see the attached example project/test case.
Summary from the attached test case:
Given this mapping:
The following test case wil fail due to :java.lang.IllegalArgumentException: Non-entity object instance passed to evict : be.test.Child
If we now alter the mapping file but use class instead of entity-name:
The same test case does work.