Hi
I'm doing some speed-testing on Hibernate vs. my companys old databaseservice, and experiencing some slow behavior from Hibernate. When trying to load 256 objects from my database, Hibernate seems to take some time at initializing the object..
I'm using:
* Hibernate 2.1.3
* MSSQL Server (Remote location)
* JTDS v. 0.8
A small clip from my log4j output:
12:02:55,404 DEBUG Loader:404 - result row: 1086954809560 12:02:55,420 DEBUG Loader:535 - Initializing object from ResultSet: 1086954809560
(I've tried to turn off the logging but the time spent do not decrease..)
As you see Hibernate takes about 16 ms to intialize each object. Is this normal?
My Java code between open- and closeSession:
private List getObject(String hql) throws HibernateException { ArrayList temp = new ArrayList(); Session session ; Transaction transaction = null; try{ session = HibernateUtil.currentSession(); transaction = session.beginTransaction(); temp = (ArrayList) session.find(hql); transaction.commit(); }catch(HibernateException e){ e.printStackTrace(); if(transaction!=null) transaction.rollback(); } return temp; }
The method called:
public ObjectA[] getAllObjectA() throws HibernateException { //------HQL------------ String hql = "from ObjectA order by sortIndex"; //------HQL------------ List temp = getObject(hql); Kpi[] ret = new Kpi[temp.size()]; temp.toArray(ret); return ret; }
hibernate.properties:
#define query langugage constants/function names hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'
##PLATFORM #MySQL
## JNDI Datasource
#hibernate.connection.datasource jdbc/quickstart
## MS SQL Server
hibernate.dialect net.sf.hibernate.dialect.SQLServerDialect hibernate.connection.username secret hibernate.connection.password secret hibernate.connection.driver_class net.sourceforge.jtds.jdbc.Driver hibernate.connection.url jdbc:jtds:sqlserver://10.10.10.2:1433/test_hibernate hibernate.jdbc.use_scrollable_resultset false
#Hibernate Connection Pool #hibernate.connection.pool_size 5
hibernate.connection.provider_class net.sf.hibernate.connection.C3P0ConnectionProvider
########################### ### C3P0 Connection Pool### ###########################
hibernate.c3p0.max_size 4 hibernate.c3p0.min_size 2 hibernate.c3p0.timeout 5000 hibernate.c3p0.max_statements 100 hibernate.c3p0.idle_test_period 3000 hibernate.c3p0.acquire_increment 2 ##hibernate.c3p0.validate false
##MISCELLANEOUS SETTINGS #Show SQL hibernate.show_sql false #auto shema export #hibernate.hbm2ddl.auto update
#set the the maximum JDBC 2 batch size (a nonzero value enables batching) hibernate.jdbc.batch_size 0
#use streams when writing binary types to/from JDBC hibernate.jdb.use_streams_for_binary true
#Set the maximum depth of the outer join fetch tree hibernate.max_fetch_depth 1
#transaction factory hibernate.transaction.factory_class net.sf.hibernate.transaction.JDBCTransactionFactory
The mapping file is straightforward except one one-to-many association wich is set to lazy. We're using assigned id-generator, but that should not cause speed problem?
To summarize - Hibernate takes to long initializing my objects.
[/b]
|