-->
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: org.hibernate.Session.save takes too long time!!!
PostPosted: Fri Sep 14, 2012 7:29 am 
Newbie

Joined: Sat Mar 27, 2010 2:43 am
Posts: 8
Hi I am using TENEO which in turn uses Hibernate.

TENEO is having an ecore model and it will be loaded with a file of size 60MB.

The ecore will be persisted in database using Hibernate by TENEO. But this process is taking too long time.

My Properties settings are as below

Code:
props.setProperty(Environment.DIALECT, org.hibernate.dialect.Oracle10gDialect.class.getName());
      props.setProperty(Environment.DEFAULT_SCHEMA,"MARS_DGS_ADMIN");
      props.setProperty("hibernate.temp.use_jdbc_metadata_defaults","false");
      props.setProperty(PersistenceOptions.CASCADE_POLICY_ON_NON_CONTAINMENT,"REFRESH,PERSIST,MERGE");
      props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,"JOINED");
      props.setProperty("teneo.mapping.default_cache_strategy","READ_WRITE");
      props.setProperty("hibernate.cache.region.factory_class", "org.hibernate.cache.ehcache.EhCacheRegionFactory");
      props.setProperty("hibernate.cache.use_second_level_cache","true");
      props.setProperty("teneo.mapping.always_version","false");
      props.setProperty("teneo.mapping.disable_econtainer","true");
      props.setProperty(Environment.HBM2DDL_AUTO, "create");
      props.setProperty("teneo.naming.max_sql_name_length","30");
      props.setProperty("hibernate.jdbc.batch_size", "30");


And the code that writes data to DB is below

Code:
final SessionFactory sessionFactory = hbds.getSessionFactory();
{
   // Open a new Session and start transaction.
   final Session session = sessionFactory.openSession();
   session.beginTransaction();

   session.save(tempSession); // Taking too long time

   // Commit the changes to the database.
   session.getTransaction().commit();
}


How to solve this problem?

My ecore is having 25 EClass. Loading the 60Mb file to model takes 6 seconds but insertion of data takes 1 hour!!!


Top
 Profile  
 
 Post subject: Re: org.hibernate.Session.save takes too long time!!!
PostPosted: Fri Sep 14, 2012 11:58 pm 
Beginner
Beginner

Joined: Fri Sep 14, 2012 10:41 am
Posts: 20
I have a feeling that something is wrong in your meta-model hibernate file. There are many errors that can make saving take a very long time, like having to many transitive savings (excessive cascade="all").

I don't know how much you know about the hibernate meta-model declaration. I suggest your review all your class declarations and watch for cascade="" and the general health of your declarations.


Top
 Profile  
 
 Post subject: Re: org.hibernate.Session.save takes too long time!!!
PostPosted: Tue Sep 18, 2012 2:27 am 
Newbie

Joined: Sat Mar 27, 2010 2:43 am
Posts: 8
I dont create any meta model, it will be taken care by Teneo. All i provide is the ecore model and Teneo which in turn uses hibernate, creates the database tables for me and all i need to persist the model is to use Session.save().

Can you please explain why you said cascade="" must be used?


Top
 Profile  
 
 Post subject: Re: org.hibernate.Session.save takes too long time!!!
PostPosted: Tue Sep 18, 2012 3:20 am 
Newbie

Joined: Sat Mar 27, 2010 2:43 am
Posts: 8
I just now enabled logging and saw that hibernate is executing lot of

Code:
Hibernate: select testdatabase.hibernate_sequence.nextval from dual


How to avoid this?


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.