Java Mailing List Archive

http://www.gg3721.com/

Home » users.openjpa »

Incredible set of statements

Beniamin Mazan

2008-07-04

Replies: Find Java Web Hosting

Author LoginPost Reply

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
--
Sent from the OpenJPA Users mailing list archive at Nabble.com.

©2008 gg3721.com - Jax Systems, LLC, U.S.A.