-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: how to create session factory?
PostPosted: Tue Aug 10, 2004 9:58 am 
Newbie

Joined: Wed Jan 07, 2004 6:13 am
Posts: 13
Hibernate version: 2.16
Name and version of the database you are using: db2 8.1
I have more than 400 tables in my system. so i have to search a
good method to create and manage session factory.
At first, i put all hbm declare in the same hibernate.cfg.xml, and
create the only session factory for the whole application.

But i find it's diffcult to maintain this xml file. and I also meet a performance problem. the performance of query is very slow.
it will spend 200ms to find a simple object in 10,000 records.
but When i create a separatly session factory for some specifily
hbm, the performance is ok. I never use the association of objects.


So, is anyone can give me some advices?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 10, 2004 10:05 am 
Regular
Regular

Joined: Mon Feb 23, 2004 10:42 pm
Posts: 102
Location: Washington DC
The RED BOX!!!!!!

When asking questions, give at least:
# the Hibernate version
# your mapping documents
# the Java code between sessionFactory.openSession() and session.close()
# the full stack trace of any exception that occurs
# the name and version of the database you are using
# a debug level Hibernate log excerpt is also appreciated

--------------------
Can you give us an example of one of the tables, mapping, and the code b/w the openSession and session.close() that is slow? Without anything else the community can't can't help!

_________________
Matt Veitas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 10, 2004 11:29 am 
Senior
Senior

Joined: Fri May 14, 2004 9:37 am
Posts: 122
Location: Cologne, Germany
So you got all mappings inside the cfg.xml file ? If I remember the docu of hibernate right then that is not a very good idea and having one large file will end up in performance problems.
Some further information would be great as mveitas already mentioned.

_________________
regards

Olaf

vote if it helped


Top
 Profile  
 
 Post subject: Re: how to create session factory?
PostPosted: Wed Aug 11, 2004 12:40 am 
Newbie

Joined: Wed Jan 07, 2004 6:13 am
Posts: 13
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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.