[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1) Optimize Hibernate for the bulk insertion of related entities

Martin Ross (JIRA) noreply at atlassian.com
Tue Nov 28 12:57:09 EST 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1?page=comments#action_25453 ] 

Martin Ross commented on HHH-1:
-------------------------------

Hi Michael,

Thanks for comments...  I'm new to hibernate so not very clear on how everything works...

As for 1) I think the reason we need to traverse is the following...

Take four queued insert actions

Class Parent
{
  int pk;
}

Class Child
{
  int pk;
  Parent parent;
}

Class Toy
{
  int pk;
  Child owner;
} 

Class ManufactureDate
{
   int pk;
   Toy toy;
}

And a default (and correct) insertion order of:
Parent
Child
Toy
ManufactureDate


We want ManufactureDate.compareTo(Parent) ==1, yes?  Under your implementation It will return 0.  I found this out when I ran your code and tested it (along with my own changes).  The problem is that we can't just rely on the fact that the items are sorted in the correct order before mergeSort() is called since compareTo can be called between any two items in the insertAction queue, not just immediate relations.  And mergeSort() relies on a correct implementation of the compareTo() method to end up with a correctly sorted list although I guess if we used bubble sort instead of mergeSort we might be okay :)

Does this argument make sense to you?   Am I missing something really simple? As far as I can tell we need a way to tell compareTo any two hibernate entities and the only way I can see this is to do a graph traversal.

2)  This is basically what I added to my code when I was trying to get it to work.

3)  I was referring to the wrinkle in implementing a graph traversal algorithm.



> 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




More information about the hibernate-issues mailing list