-->
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: select before insert?
PostPosted: Wed Jun 13, 2007 1:45 pm 
Newbie

Joined: Wed Jun 13, 2007 1:42 pm
Posts: 2
Hi,

I'm using JPA and before insert there is a select for each Entity. Is it possible to do insert (or update/delete) without select, because it just kills performance.

TIA


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 3:20 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
your id property seems to be broken preventing hibernate to guess the state correctly, consider using a surrogate key

as for update, you'll need to use session.saveOrUpdate rather than em.merge

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 4:34 pm 
Newbie

Joined: Wed Jun 13, 2007 1:42 pm
Posts: 2
Thank for your reply.

The scenario:

1. I get collection of Entities from one EntityManagerFactory/EntityManager

2. In loop I set some values and I want to insert the Entities into
second DB using different EntityManagerFactory/EntityManager using merge(). It works, however there is select for each insert, which affects performance.

The solution is to use persist(). Now there are no selects!

Thanks


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.