Hibernate version: hibernate2.16
Mapping documents:
Code:
<session-factory>
<property name="hibernate.connection.provider_class">net.sf.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">200</property>
<property name="hibernate.c3p0.validate">false</property>
<property name="hibernate.dialect">net.sf.hibernate.dialect.DB2Dialect</property>
<property name="hibernate.connection.driver_class">COM.ibm.db2.jdbc.app.DB2Driver</property>
<property name="hibernate.connection.url">jdbc:db2:xx</property>
<property name="hibernate.connection.username">xxx</property>
<property name="hibernate.connection.password">xxx</property>
<property name="show_sql">false</property>
<property name="show_sql">false</property>
<!-- Mapping files more than 400-->
</session-factory>
one mapping file
Code:
<hibernate-mapping>
<class name="xxx.Products" table="Products">
<id name="id" column="id" type="string" length="50">
<generator class="uuid.hex" />
</id>
<property name="activity" column="activity"/>
<property name="hour" column="hour"/>
<!--- about 20 property --->
<property name="type" column="type"/>
</class>
<!--- don't define any assocation in objects---->
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():create factory and open a sessino
Quote:
config = (new Configuration()).configure();
factory = config.buildSessionFactory();Session session = sessionFactory.openSession();
execute a query
Code:
Query query = session.createQuery("xxx");
return query.list()[0];
it need 200ms to get the result.
Name and version of the database you are using: db28.12
sorry, i just thought it's a popular problem .
When i try to change the code of create session factory, it can work well,
look the below code
Code:
config = new Configuration();
config.add(Products.class)
.... add 5 classes
the query only consume 30ms
[/code]