I got Entity with relation to itself like :
public class ActionLog {
@ManyToOne(cascade = {CascadeType.MERGE, CascadeType.REFRESH}, fetch =
FetchType.EAGER)
@JoinColumn(name = "product_id", nullable = false)
private Product product;
@ManyToOne(cascade = {CascadeType.MERGE, CascadeType.REFRESH}, fetch =
FetchType.EAGER)
@JoinColumn(name = "parent_id", nullable = true)
private ActionLog parent;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy
=
"parent")
@OrderBy(value = "created DESC")
private List<ActionLog> children = new ArrayList<ActionLog>();
}
When I execute named query to load Product with ActionLogs :
SELECT p FROM Product p LEFT JOIN FETCH p.logs WHERE p.id = :id
OpenJPA generates strange set of select.
At first is selects all ActionLogs for specified Product - it's OK. But next
it build single statement to select children of each ActionLog has been
found in the first step.
Couldn't it be made simplier?
Beniamin
-----
--
thanks
Beniamin
--
View this message in context:
http://n2.nabble.com/Incredible-set-of-statements-tp221053p221053.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.