Bulk insert of component collection in Hibernate? -


i have mapping listed below.

when update detached categories item (that doesn't contain hibernate class comes dto converter) notice hibernate first delete employer wages instances (the collection link) , insert employer wage entries one-by-one :(...

i understand has delete , insert entries detached.

but, don't understand, why hibernate not inserting entries through bulk-insert?.. is: inserting employer wage entries in 1 sql statement ?

how can tell hibernate use bulk-insert? (if possible). tried playing following value didn't see 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> 

bulk-insert - specific native way for fast inserting, doing native external tools bcp.exe ms sql. talking batch-insert, try using code example:

session session = sessionfactory.opensession(); transaction tx = session.begintransaction();  ( int i=0; i<100000; i++ ) {     customer customer = new customer(.....);     session.save(customer);     if ( % 20 == 0 ) { //20, same jdbc batch size         //flush batch of inserts , release memory:         session.flush();         session.clear();     } }  tx.commit(); session.close(); 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -