merge « Insert « JPA Q&A





1. JPA merge does not appear to work    stackoverflow.com

I'm running the following code to update the database according to the data I read from CSV file. I've tried to debug, and check the console and it's running through the ...

2. jpa hibernate merge performs insert instead of update    stackoverflow.com

I have a simple test, where I am trying to update the object. but merge seems to be performing an insert instead of update.

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring/app-context.xml","classpath:spring/testdb-context.xml"})
public class UserJPATest {
@Test
public void ...

3. Hibernate merge cascading a collection's insert    stackoverflow.com

Have a setup with Hibernate 3 whereby inserting collections through an inverse many-to-one relationship doesn't automatically set the parent's foreign key in the child when merging. For example, in the Element class ...

4. [JPA] merge() is inserting instead of updating    coderanch.com

hi, can anyone enlighten me regarding the mecanism of persistence in EJB 3.0 ? I am trying to update an entity in the database from a web client that calls a method in a stateful session bean. That method looks like this : @Stateful public class TestOneAction implements TestOneLocal { @PersistenceContext(unitName="unitTest") private EntityManager em; public void updateEntity(Entity entity) { em.merge(entity); } ...

5. merge() generated a "insert" SQL for managed Entity, why?    forum.hibernate.org

hihi, When I using EntityManager.merge() method to update a Entity (team.class) that contained a list of Child Entities (member.class). Before call EntityManager.merge() method, I uses entityManager.contains() method to ensure the Child Entities are managed. The method returns "true". but when I call EntityManager.merge(team) to update the parent entity, hibernate generated the "insert" SQL to update child entity and display "unique constraint" ...

6. Session.merge also inserts data    forum.hibernate.org

7. Bug? Duplicate insert: @OneToMay with cascade "all" & merge    forum.hibernate.org

Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message bfreis Post subject: Bug? Duplicate insert: @OneToMay with cascade "all" & merge Posted: Fri Dec 17, 2010 10:21 am Newbie Joined: Wed Sep 09, 2009 6:05 am Posts: 2 I have encountered a strange behavior of ...

8. EnitityManager merge cause two inserts for collection    forum.hibernate.org

I have an entity MainEntity MainEntity has a collection of ChildEntity. I do the following: 1. ChildEntity ch = new ChildEntity(); 2. MainEntity me = getMainEntity(mainEntity ID); // this will retrieve the MainEntity from database 3. ch.setMainEntity(me); 4. me.getChildEntityCollection().add(ch); 5. EnittyManager.merge(me). This cause 2 inserts for Child entity. The primary key for the entity is auto generated. The child entity is ...

9. The session.merge(obj) is inserting one extra record    forum.hibernate.org

I am using merge to save the data in the database, but I am getting and extra record. Somebody can give me an idea to fix this problem. I believe that the problem is in the mapping file but I do not know what to do to resolve this problem. Hibernate version: 3.0.2 Mapping documents:





10. merge(parent). 2 inserts and one update    forum.hibernate.org

I have the following code that according to hibernate logging sql results in 1. insert parent 2. insert child 3. update parent(why is this happening?) Here is the transaction code.... Code: mgr.getTransaction().begin(); ParentDBO parent = new ParentDBO(); ...

11. Session.merge uses insert instead of update    forum.hibernate.org

Newbie Joined: Fri Jul 21, 2006 6:27 am Posts: 10 hi all! Problem Description: im using hibernate together with EMF 2.2.0 and elver. when calling Session.merge with an object already present in the dbtable(meaning: there's another object of the same type and id in the db - but with different details/values) - merge tries to do an insert instead of an ...