Hi
i have a parent class Track which contains some thousands child instances of type Location:
------------------------
class Track {
...
@OneToMany(mappedBy = "track", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@OrderBy("timestamp ASC")
@OnDelete(action=OnDeleteAction.CASCADE)
public List<Location> getLocations() {
return locations;
}
}
------------------------
When i insert a new Location instance:
------------------------
track.addLocation(location);
em.persist(location);
return location.getLocationId();
------------------------
the EntityManager triggers thousands of selects for all sibling Location instances
until it finally inserts the new Location which slows down the DB layer
to some minutes for one insert.
What can i do?
Can i insert the Location natively or add some clever annotation?
Thanks
Marcel
Hibernate 3.2 cr2, jboss-EJB-3.0_RC9_Patch_1
PostgreSQL 8.1.5, Linux 2.6.18
|