saveOrUpdate « Session « JPA Q&A





1. Hibernate saveOrUpdate with another object in the session    stackoverflow.com

Is there any way to save an object using Hibernate if there is already an object using that identifier loaded into the session?

  • Doing session.contains(obj) seems to only return true if the ...

2. What are the differences between Hibernate Session methods saveOrUpdate() and merge()?    stackoverflow.com

What are the differences between Hibernate Session methods saveOrUpdate(Object) and merge(Object)? It seems that both methods generate an SQL

3. Differences among save,update,saveorupdate,merge method in session object?    stackoverflow.com

i am new to hibernate and went thru hibernate tutorial in last week. I have few doubts about methods save,update,saveorupdate,merge in session object. These are:- save method:- it is used to insert ...

4. session.saveOrUpdate vs. session.saveOrUpdateCopy    forum.hibernate.org

hi folks - I'm using session.saveOrUpdateCopy(), to update certain fields in entities, which is working fine, except in a particular situation with cascade="all-delete-orphan" on a collection of entities. the basic setup is: Entity e1 has a reference to another entity e2. e2 has a reference to e3 e3 has a cascade="all-delete-orphan" collection (Set) of e2 In our system, I would like ...

5. ClassCastException after invoking session.saveOrUpdate    forum.hibernate.org

Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message dalton Post subject: ClassCastException after invoking session.saveOrUpdate Posted: Wed Apr 14, 2004 11:23 am Newbie Joined: Wed Apr 14, 2004 10:52 am Posts: 2 Location: cary, nc Hi, I have been researching a problem with Hibernate ...

6. session.save works but session.saveOrUpdate doesnt work    forum.hibernate.org

Hi, I have Hibernate 2.1.4. I have a class with an int primary key, which is "assigned" type. When I create a new instance and "session.save()" to the DB, it works fine (creates an insert SQL). However, when I change "save()" to "saveOrUpdate()", I get an exception: net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found) at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25) at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:689) ...

7. session.update and session.saveOrUpdate fails    forum.hibernate.org

Newbie Joined: Fri Oct 17, 2003 6:11 am Posts: 15 I have a problem, using saveOrUpdate or update methods, my DB isn't written. No error messages are returned, No rollbacks happen. Do you have any ideas? Hibernate version: 2.1.4 Mapping documents: it.rvspm.siscotel.portal.dao.AbstractWebObject

8. puzzle with session.saveOrUpdate    forum.hibernate.org

puzzle with session.saveOrUpdate I have two DAO class , they implement a method named saveOrUpdate. It's codes like: Code: public Serializable saveOrUpdate(Object obj) throws DataAccessException { Session session = null; try { session = sessionFactory.openSession(); ...

9. session.merge & saveOrUpdate->NonUniqueObjectExceptio    forum.hibernate.org

Expert Joined: Mon Jan 09, 2006 5:01 pm Posts: 311 Location: Sacramento, CA Tested with Hibernate 3.1.2, java 1.5.0_05 Here is a test case - basically testing to see if session.MERGE () works correctly, as stated in the docs. The test shows that it doesn't!!! From the docs, the session.merge(object) function should do this: Quote: The state of a transient or ...





10. Help with session.saveOrUpdate()    forum.hibernate.org

Hi, I am having problem with saveOrUpdate. (ONly when doing an Update) I create a database object. Account a = new Account(); where Account is a table with 10 columns, out of which 2 keys form the composite primary key. I set values for 5 columns like... (assume Name and ID form composite Keys) a.setName("aaa"); a.setId("12"); ...... after that I call ...

11. Session.merge() fails, Session.saveOrUpdate() works    forum.hibernate.org

Author Message tima Post subject: Session.merge() fails, Session.saveOrUpdate() works Posted: Fri Nov 02, 2007 12:50 am Newbie Joined: Wed Oct 04, 2006 2:47 am Posts: 12 Can anyone explain why the following use of Session.merge() fails with a ConstraintViolationException, but replacing merge() with saveOrUpdate() succeeds? Using merge(), hibernate attempts to insert the Relationship instance associated with partA and partB ...

12. session.update & saveOrUpdate    forum.hibernate.org

Hi, We are using hibernate 3.0. We are using session.saveOrUpdate to insert a new value into the database & to update the existing entry. So, if the searched value which is to be updated is unavailable that value will be inserted into the table. But if we don't want to insert a new record & we want only a pure update, ...