Issue
I have a detached entity with a One-To-Many join.
@Entity
@Table("t1")
class Entity1 implements Serializable {
...
@OneToMany(cascade=CascadeType.ALL)
@JoinColumns({
@JoinColumn(name="FIELD_1", insertable = false, updatable = false, referencedColumnName = "FIELD_1"),
@JoinColumn(name="FIELD_2", insertable = false, updatable = false, referencedColumnName = "FIELD_2")
})
public List<Entity2> getListOfEntities() {
return listOfEntities;
}
}
@Entity
@Table("t2")
class Entity2 implements Serializable {
...
}
When I call entity1Merged = entityManger.merge(entity1)
where entity1 is of class Entity1, among other things the entityManager
falls down to the list of joined entities, loads them from the database, merges them, but apparently the result of the merged Entity2 objects aren't being assigned to the list listOfEntities of the new entity1Merged.
Solution
It is a bug in version 5.2.12 of hibernate tracked with the issue https://hibernate.atlassian.net/browse/HHH-12054 and resolved from version 5.2.13+.
Answered By - 500 Server error
Answer Checked By - Terry (JavaFixing Volunteer)