Child entity has the follwoing key:
@Id
private Long id;
@Id
@ManyToOne
@JoinColumn(name = "parent_id")
private Parent parent;
When I'm trying to fetch parent with children I get StackOverflowException (on H2) or "to0 many cursors" SQLException (on Oracle).
If hibernate.show_sql is turned on - one and the same query is written to stdout multiple times.
Full example is in the attachment or on github: https://github.com/isopov/hibernate-fetch-eager-composite-key-test
I will appreciate any comments regarding workarounds or bad practices that are used in this example (I'm a newcomer to Hibernate)
|