I think I must be stupid or something, but I just don't' get the logic
behind joins in OpenJPA. Here is an example:
@Entity
Public class User {
@Id
String somekey;
@OneToOne(fetch=FetchType.LAZY,cascade={CascadeType.Refresh})
UserProfile profile;
@OneToMany(fetch=FetchType.LAZY,cascade={CascadeType.ALL})
private List<Alert> alerts
@OneToMany(fetch=FetchType.LAZY,cascade={CascadeType.Refresh})
private List<Address> locations;
}
When I query the User class OpenJPA will query every single joined entity
and any entity that is joined to that entity etc etc, a horribly
inefficient query when all I want is to retrieve the user itself and not
everything joined and joined and joined to the locations list.
Similarly, when merge a User entity, the resulting update query is updating
ever entry the locations collection, when the only purpose of the
CascadeType.Refresh, is to force OpenJPA to create a join between User and
it's associated address's.
I'm using 2.0 Beta 3 but been battling with 1.2.x for the last year or so.
I use table per class.
One of my updates is so inefficient, a query against the DB using straight
SQL will take milliseconds, but OpenJPA will take 1 minute per row.
Chris