From: Michael K. (JIRA) <no...@at...> - 2006-03-16 15:38:55
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1?page=comments#action_22511 ] Michael Kopp commented on HHH-1: -------------------------------- I have a new and rather simple aproach on this on. Hibernate knows how insert are to be ordered. Basically its done during the cascade. SaveEvent: cascadeBeforeSave addInsertAction cascadeAfterSave All we really need is to inform the EntityInsertAction of its parents EntityInsertAction's, thus of the once that have to happen before. The cascadeAfterSave can propergate that down the chain. and the CascadeBeforeSave can give that back. That way the code would know of the EntityInsertActions that the new one is dependent on. Once that is available, the ActionQueue.prepareActions can reorder the insert actions: - first order by EnityType - go through the list and move Entities with Parents to the end of the list - now move all entites with no parents are at the beginning - remove those toplevel entities from the dependent list of the Entities that contain them as parents. - At this point some of these changed Entites have no parents anymore others do. - start at the beginning of the loop: go through the list and move Entities with Parents to the end of the list Do this until no EntityInsertAction has a parent anymore. The resulting order will be valid and the optimum insert order! I might actually sit down and do that, provided that the hibernate guys would be willing to include that change. > Optimize Hibernate for the bulk insertion of related entities > ------------------------------------------------------------- > > Key: HHH-1 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1 > Project: Hibernate3 > Type: New Feature > Components: core > Environment: Hibernate 1.2, MySql 3.1 > Reporter: Bradley Leupen > Priority: Minor > > > It is currently difficult to batch the creation of persistent entities that maintain associations with other entities. > Add necessary api to hibernate to support the save or update of a collection of entities. An optimization can be applied in this scenario to group inserts / updates by entity class, or table. This will enable the hibernate engine to utilize batching if available, drastically improving performance over a network. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |