Hibernate version:
2.1.8
Mapping documents:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.cegedim.example.domain">
<class name="Tirage" table="TIRAGE">
<id name="tirageID" column="TIRAGE_ID" type="java.lang.Long">
<generator class="native"/>
</id>
<property
name="date"
column="DATE"
type="java.util.Date"/>
<property
name="nbGagnant"
column="NBGAGNANT"
type="java.lang.Integer"/>
<set name="numerosGagnants" lazy="true">
<key column="TIRAGE_ID"/>
<one-to-many class="com.cegedim.example.domain.NumeroGagnant"/>
</set>
<many-to-one name="loto" class="com.cegedim.example.domain.Loto" column="LOTO_ID"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Transaction tx = session.beginTransaction();
for( int i=0 ; i<count ; i++ )
{
Tirage tirage = new Tirage( new Date(System.currentTimeMillis()),
new Integer(0),
loto,
null);
session.save(tirage);
}
session.flush();
tx.commit();
Name and version of the database you are using:
MySQL 4.0.23
Hibernate.properties:
hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class = com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost/loto?autoreconnect=true
hibernate.connection.username=root
hibernate.connection.password=
hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
hibernate.show_sql = false
hibernate.cache.use_second_level_cache = false
hibernate.jdbc.batch_size = 20
Questions:
I want to proceed mass insertion. About 60.000 records.
I enable batch-size but it seems not work.
The goal is to have same performance with Hibernate and SQL native
I make a test application to mesure performance
The test is 20 pass of 100 inserts and 20 pass of 1000 inserts
Performance reports
20*100 inserts
Average Hibernate = 83.5
Average native preparestatement = 43.8
Performance ratio = 1.906392694063927
20*1000 inserts
Average Hibernate = 421.0
Average native preparestatement = 213.05
Performance ratio = 1.9760619572870217
|