Hi,
I'm using Hibernate 3.6 and I'm experiencing a weir behaviour while manipulating collections. In my case, I'm using the "set" element in hbm.xml like this:
<class name="Person" table="PERSON"> <id column="DBID_" name="dbid"> <generator class="native" /> </id> <property name="name" column="NAME" type="string" /> <set name="adresses" cascade="all" table="ADDRESS" fetch="join"> <key foreign-key="FK_PERSON_ID"> <column name="PERSON_ID" index="IDX_ADDRESS"/> </key> <element type="string" column="ADDRESS"/> </set> </class>
My code is creating a new Person and add 100 addresses inside. I have monitored the statements generated (using MySQL logs) and I got 100 insert statements into table ADDRESS. I tried the various batch size properties in hibernate configuration but it does not help. hibernate.jdbc.batch_size 100 hibernate.jdbc.batch_versioned_data true hibernate.default_batch_fetch_size 100 hibernate.jdbc.fetch_size 100
I also read in the documentation that I can set batch-size attribute in my mapping but this would only affect the fetching of addresses from a person correct?
Do you know how I can reduce the number of insert statements to insert my 100 rows?
Thanks, Charles
|