session « Delete « JPA Q&A





1. Hibernate Session.delete() an object if exists    stackoverflow.com

In JavaDoc of Session class the description of delete method is:

Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving ...

2. Named parameters with a session.delete()?    forum.hibernate.org

With a List of PKs (Integers), I'd like to delete a bunch of records without loading them into the session. session.delete("from Result result where result.id in (:ids)", resultids, Hibernate.INTEGER); gives me a ClassCastException Query q = session.createQuery("from Result result where result.id in (:ids)"); q.setParameterList("ids", resultids, Hibernate.INTEGER); session.delete(q.getQueryString()); tells me the parameter isn't specified. What am I doing wrong? Thanks for any ...

3. basic question about session.delete()    forum.hibernate.org

Well Im also new in Hibernate, but like I understand when you want to delete an object you need to have this object, so you can get the object with load sentence or with finder method (you need to extract specific object from list). I'm not sure if exist other form for access an object but if you know something maybe ...

4. session.delete in :aList    forum.hibernate.org

Gavin, i couldn't find a way to do session.delete for a list of primarykeys. i wanted to say "delete from mytable where pk in (:mylist)" i can do in queries with criteria,using Expression.in, however since session.delete requires a select query string, i couldn't fit my criteria into that. are there any plans to implement session.delete for a collection? i had to ...

5. object deleted in multiple sessions    forum.hibernate.org

Hi! Anyone have any idea what is the best aproach for this situation : I have to hibernate sessions, S1 and S2, and I load two objects with the same primary key, O1 loaded by S1 and O2 loaded by S2. The problem appear when I delete first O1 and then O2, as hibernate throw an exception if the coresponding row ...

6. NPC from Session.delete(Object) after upgrading to 2.1.1    forum.hibernate.org

Hello, After upgrading my application from 2.0 to 2.1.1, I'm getting a NullPointerException with some Session.delete(obj). The code supposedly ran fine before, therefore I started tracing 2.1.1 source code. After persevering for a long long time... I find that the NullPointerException originated in PersistentCollection : static void identityRemove(Collection list, Object object, SessionImplementor session) throws HibernateException { if ( object!=null && session.isSaved(object) ...

7. problems on session.delete()    forum.hibernate.org

9. Session.delete object from assoications    forum.hibernate.org

I delete object usign Session.delete method. After flush (I have FlushMode NEVER) I get this exception: net.sf.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): I catch it and rollback currenct transaction. Next time I call flush, I get this exception again and again. How can I rollback object deletion? Thx, Lukas





10. What is the replacement for Session.delete in 3beta?    forum.hibernate.org

Hello: I'm trying to migrate to Hibernate 3beta and I noticed that Session.delete(String) methods have been deprecated. There is a vague comment explaining that we should use createQuery instead. I can't figure out how to use "createQuery" in order to delete records returned by the query. Could somebody shed some light on this? Thanks a lot, Alexander

11. session.delete() fails, Hibernate raises ObjectDeleted Excpn    forum.hibernate.org

Hibernate version:2.1.7 Even if session.delete() fails, and raises HibernateException, Hibernate marks the object as deleted I am trying to figure out whether the StaleObjectStateException is being raised because 1. A row with the specified ID did not exist - "usr-msg: Contact System Administrator" 2. This row was updated in another session - "usr-msg - This data was updated by another user. ...

12. Deleting many objects within same session dramatically slow!    forum.hibernate.org

Hi, I investigated on this problem in the formun and could not find any messages addressing it. Ok here the description (Hibernate version is 2.1.7c): When you delete a huge amount of objects within the same hibernate session, the "nullifiables" set fills up. This is a problem if you use "Lifecycle" enabled objects. Every single delete clones the "nullifiables" set and ...

13. session.delete results in UPDATE.. SET..    forum.hibernate.org

aturetsky Post subject: as requested, here are the details Posted: Wed Feb 02, 2005 7:23 pm Regular Joined: Fri Jan 28, 2005 3:11 am Posts: 81 Read the rules before posting! http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 2.1.8 Mapping documents: hibernate.cfg.xml

17. Get created / updated / deleted entities out of a session.    forum.hibernate.org

Hi, I'd like to obtain information about which entities (instances) were created / updated / deleted during a given session, up until the moment of flushing. Rationale: before flush, I'd like to execute some additional business logic (amongst wich validation) on these entities. Currently, I wrote an interceptor that maintains a created / updated / deleted collection by itself. It adds ...

18. session.delete(object) not working properly    forum.hibernate.org

Hi All, I am using Hibernate3.2.3. I am facing problem while deleting an object which is having composite key. When I call session.delete(object) method with with wrong set of composite key( it means that composite key is not in the database) I dont get any exception. Unless and untill I dont get exception I wont be able to know whether my ...