|
Let's assume we have the following entities:
@Entity
@Table(name = "foo")
public static class Foo {
@Id
@GeneratedValue
public Integer id;
@ManyToOne(fetch = FetchType.LAZY)
public Bar bar;
@ManyToOne(fetch = FetchType.LAZY)
public Baz baz;
}
@Entity
@Table(name = "bar")
public static class Bar {
@Id
@GeneratedValue
public Integer id;
@OneToMany(mappedBy = "bar")
public Set<Foo> foos = new HashSet<Foo>();
}
@Entity
@Table(name = "baz")
public static class Baz {
@Id
@GeneratedValue
public Integer id;
@OneToMany(mappedBy = "baz")
public Set<Foo> foos = new HashSet<Foo>();
}
Assume also that we have two entity graphs:
-
Graph A targets only the bar attribute => [bar]
-
Graph B targets both bar and baz attributes => [bar, baz]
Now, in one level 1 session:
-
fetch a foo entity with graph A
-
fetch the same entity with graph B
Consequence: bar is initialized, not baz Expected: bar and baz should have been initialized
This is highly problematic when attribute initialized state is mandatory for some operations or modules (i.e. Jackson Hibernate module)
A test case is going to be submitted in a new PR.
|