Bulk insert of component collection in Hibernate?

Posted by edbras on Stack Overflow See other posts from Stack Overflow or by edbras
Published on 2011-01-25T18:47:44Z Indexed on 2011/11/13 9:51 UTC
Read the original article Hit count: 292

I have the mapping as listed below.

When I update a detached Categories item (that doesn't contain any Hibernate class as it comes from a dto converter) I notice that Hibernate will first delete ALL employer wages instances (the collection link) and then insert ALL employer wage entries ONE-BY-ONE :(...

I understand that it has to delete and then insert all entries as it was completely detached.

BUT, what I don't understand, why is Hibernate NOT inserting all the entries through bulk-insert?.. That is: inserting all the employer wage entries all in one SQL statement ?

How can I tell Hibernate to use bulk-insert? (if possible). I tried playing with the following value but didn't see any difference:

hibernate.jdbc.batch_size=30

My mapping snippet:

<class name="com.sample.CategoriesDefault" table="dec_cats" >
 <id name="id" column="id" type="string" length="40" access="property">
  <generator class="assigned" />
 </id>
 <component name="incomeInfoMember" class="com.sample.IncomeInfoDefault">
   <property name="hasWage" type="boolean" column="inMemWage"/>
    ...
   <component name="wage" class="com.sample.impl.WageDefault">
     <property name="hasEmployerWage" type="boolean" column="inMemEmpWage"/>
      ...
     <set name="employerWages" cascade="all-delete-orphan" lazy="false">
      <key column="idCats" not-null="true" />
      <one-to-many entity-name="mIWaEmp"/>
     </set>
   </component>
 </component>
</class>

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about hibernate-mapping