-->
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.  [ 3 posts ] 
Author Message
 Post subject: Batch insertion & EJB3
PostPosted: Tue Jan 31, 2006 7:20 am 
Beginner
Beginner

Joined: Fri Oct 07, 2005 5:35 am
Posts: 38
Location: France
In my application I use the same session beans to create new persistent objects when objects are created in batch mode or by a client.

I have implemented something which looks like the Patch processing chapter in hibernate documentation.

All my session beans uses another SessionBean to persist objects instead of using directly the entity manager. The Session Bean in charge of persisting objects count persisted instance and flush and clear the entity manager every x objects (with x=hibernate.jdbc.batch_size)

Code:
public class PersistenceServiceBean {
@PeristenceContext
private EntityManager em;
public void persist(Object o) {
   if (count%20 ==0) {
      em.flush();
      em.clear();
   }
   em.persist(o);
}
}


It makes the performance better than never flushing explicitely but I'm not very happy with that design. All my session beans that persists objects have to use my PersistenceServiceBean instead of the EntityManager. I am not able to detect if one bean uses directly the entity manager.

Is is possible to have an auto flush counter setting in the configuration (in that case I may use the entity manager directly) ?

Ideas for another design are welcome ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 4:49 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you could use the stateless session for that

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 12:32 pm 
Beginner
Beginner

Joined: Fri Oct 07, 2005 5:35 am
Posts: 38
Location: France
I'm not sure it will be a good idea in my case. In fact in my application, I'd like to use the same session bean to create objects in batch mode and in routine mode. In routine mode, I do other stuff in the same transaction (such as query, ...).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.