collection « Delete « JPA Q&A





1. Hibernate : Best way to delete elements in a collection    stackoverflow.com

A problem that I often face with Hibernate is having a list (call it listA) of objects that I want to persist against an entity (myEntity) but having to first compare ...

2. Deleting thing "A" in hibernate does not update objects with collections of "A"    stackoverflow.com

Say you had a Cat, with Kittens. Then you you did a delete() on a kitten that belongs to a Cat. The Cat object still has a reference to the deleted ...

3. Hibernate deleting orphans when updating collection    stackoverflow.com

I'm finding that orphan records aren't being deleted when removing from a collection in Hibernate. I must be doing something simple wrong, (this is Hibernate-101!), but I can't find it.. Given ...

4. Cascading hibernate delete when setting a collection to 'new ArrayList()'    stackoverflow.com

I have an object mapped with hibernate that contains an id and a collection. At some point in time when the object contains items in it's collection I want to do ...

5. Problem deleting value-type object from Collection in Hibernate    coderanch.com

I'm using Hibernate. I have no problem deleting Entities (with ID value) but I seem to be having some trouble deleting regular Value type objects from a Collection. It seems to me that if you call remove(), the object should be removed. However, after doing this, the Object is removed from the Set, but when I load the View, the Object ...

6. How to indicate a collection is uninitialized vs deleted    forum.hibernate.org

I have a REST service that uses Hibernate to persist/retrieve its data. On the front end the service produces and consumes JSON. During a record update the service receives the updated JSON record, unmarshalls that in to a new bean instance, and then calls EntityManager#merge(Object). At this point I get the error "A collection with cascade="all-delete-orphan" was no longer referenced by ...

7. A collection with cascade="all-delete-orphan" was no longer    forum.hibernate.org

Hi , I have a Person class which contains collection of PersonContact objects Person{ private Collection colContact = Collections.emptyList(); public void setColContact(Collection colContact) { this.colContact = colContact; } @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @JoinColumn(name = "PRSN_ID") @org.hibernate.annotations.Cascade(value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN) public Collection getColContact() { return colContact; } } Now first am saving a Person in db without any PersonContact obj . ...

8. Problems deleting from Many to Many collection    forum.hibernate.org

I have a table structure like the following: Organization -- > OrganizationAddresses < -- Address I have and Organization object which has a mapped many to many relationship using the bag construct to organization addresses. When I try to delete an address from the organization's address list then consequently delete the address itself, I receive the following error message from hibernate ...

9. Delete collections    forum.hibernate.org





10. Deleting an object from a collection leads to race condition    forum.hibernate.org

I checked the .equals function, and it looks good to me: Code: public boolean equals(Object obj) { if (!(obj instanceof ItemIF)) { return false; } ItemIF cmp = (ItemIF) obj; boolean te; if ...

11. delete on collection element performs update on parent    forum.hibernate.org

public class Parent { // [...] /** * @hibernate.set cascade="delete" * table="children" * ...

12. Cascade updating and deleting on collection    forum.hibernate.org

Hi, I have an object Services that have 3 attributes : the name, the number and a collection of Person. A Person has 3 properties : name, surname and age adn is identified by her name and surname. The update of Person is made by cascade update when I update the Services. Now, I have hibernate that extracts from a database ...

13. How delete object from collection    forum.hibernate.org

14. How in the...? Incorrect M2M collection item deletion.    forum.hibernate.org

Problem: Haven't encountered this one before, and haven't read of anything like this in any of the forum topics. We have an indexed M2M association between Subject and Attribute. Our association table is subject_attribute. We have a junit test which populates the subject_attribute table with four associations for one particular subject. When we remove an Attribute entity from the Subject's attributes ...

15. Dereference a collection with cascade="all-delete-orpha    forum.hibernate.org

Hibernate version: 2.1.6 We're using hibernate to persist an entity with the following mapping: Code: ...

16. Deleting elements from a collection of dependent objects    forum.hibernate.org

Newbie Joined: Thu Sep 30, 2004 11:12 am Posts: 1 Hello, After failing to find a solution to this problem in the forums, I am posting it. Hope that somebody can help me. Thanks in advance. Here is the problem itself: I have two classes ActivityEntry(AE) and ActivityRecord(AR). The latter is dependent on the prior. The AE class contains a collection ...





17. Help deleting objects with collections!    forum.hibernate.org

I'm a newbi at using collections, and I'm having a problem: I'm using 2 classes, A and B, A has a set of B objects, and B has a reference to its A object. In the database, B has a reference to A, not null. When I try to delete A (the parent) the error which occurs is not because of ...

18. Deleting a sub-collection strategy    forum.hibernate.org

While there is no stable version 3.0, what would be the best way for doing this? I tried method #1 above but it didnt work . I get the following error: net.sf.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): 1363, of class: sonicBiz.DefDNS if I remove the object from the collection I get: java.util.ConcurrentModificationException

19. Conceptual collections and delete() question    forum.hibernate.org

Guys, I'm a little confused about collections and deletions. Say I have a class called Person, and that person has a list collection of Address objects. If I manually delete an Address object from the database by calling session.delete(addressObj), is it then imperative that I get ahold of the containing Person object and do a person.getAddresses().remove(addressObj) as well, or can Hibernate ...

20. Don't dereference a collection with cascade="all-delete    forum.hibernate.org

Hi, In a one-to-many relationship, I am trying to dereference a child(interface) collection and then adding a new child collection to the parent(device). When I tried this I got the HibernateException: Don't dereference a collection with cascade="all-delete-orphan" I looked at the following explanation http://www.hibernate.org/264.html because of which I tried to clear the collection and saveorupdate the object. The problem is that ...

21. help deleting items from a collection    forum.hibernate.org

Author Message jaynance Post subject: help deleting items from a collection Posted: Sat Jun 04, 2005 3:07 pm Newbie Joined: Sat Jun 04, 2005 2:35 pm Posts: 7 I am sure this is a newby question, but it sure is taking the wind out of my sails. I am trying to delete an item from a Set collection. I ...

22. unable to delete an element in a collection...    forum.hibernate.org

Jason Zhicheng Li wrote: Quote: order.getItems().remove(new Item(1)); You are mapping Item as a composite-element in the set. That is, no identifier for each row. Hibernate figures out which row to delete by checking all properties to see if they are matched. When you are issuing remove(new Item(1)), I am assuming you only set the value 1 to one property, where is ...

23. may not deref. collection with cascade=all-delete-orphan&quo    forum.hibernate.org

Newbie Joined: Tue Oct 11, 2005 1:00 pm Posts: 2 Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp The problem, obviously, only happens when I try to modify existing activtiy object that contains a set of locations, which, the set, has cascade="all-delete-orphan". Please help. Hibernate version: version 2 Mapping documents: excerpt from Activity object mapping file containing this set ...

24. Collections of dependent objects - cascading delete?    forum.hibernate.org

Hibernate version: 3.1 I read section 8.2 of the tutorial, about mapping collections of dependent objects. In that example, a set contains Name objects that are mapped as composite elements. My question is, how can I cause these composite elements to delete when the containing element is removed? Currently, I cannot remove the containing element, because attampting to removing it causes ...

25. Deleteing from a delete-orphan one-to-many collection    forum.hibernate.org

org.hibernate.exception.ConstraintViolationException: could not delete collection: [com.energyintellect.manage.connectionpoint.impl.ConnectionPointImpl.IEMUserTerms#D4919281-1E6E-4361-BAF8-6A40039A5D26] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:63) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:860) at org.hibernate.action.CollectionUpdateAction.execute(CollectionUpdateAction.java:39) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730) at com.tml.framework.datasource.impl.FrameworkSessionWrapper.flush(FrameworkSessionWrapper.java:261) ...

26. Collection members not being deleted    forum.hibernate.org

Hello, I've just started using Hibernate and have come across a small problem. I have a class RouteSet, which contains a Set of class Route (defined as a one-to-many relationship). When my app starts, I retrieve my RouteSet object from the database. My problem is this: If I then reassign the underlying set reference using RouteSet.setRoute(Set newRoutes) and persist the object, ...

28. Orphan Deletion and new collections    forum.hibernate.org

Hibernate version: 3.0.5 I am facing a problem with orphan deletion. As long as the application is working with the hibernate-modified collection instance the orphan-deletions happen correctly but if the user replaces the old collection a brand new collection then the collection table gets updated correctly but the orphaned elements (from the old collection) do not get removed from the database. ...

29. Deleting collection element doesn't work    forum.hibernate.org

Hi I've got an Offer (parent object) which contains a collection of Conditions. I'm using a bag, defined as follows: Code:

30. Delete an element from a collection of an Object    forum.hibernate.org

I have an object with a collection. What I would like to do is load the object back into my program and delete one element from the collection. I then want to update the object using update and remove the element from the database. What happens now is that the update does not remove the element in the collection. Is there ...

31. problem deleting collections    forum.hibernate.org

32. Unable to delete Value type from Collection    forum.hibernate.org

I am new to Hibernate, but I have read the tutorial and The 'King/Bauer' referrence book. I have an application built on Hibernate and it mostly works very well. I have no trouble managing Entity objects and associations of entities; I'm however having some difficulty managing a Collection of Value type objects. When I attempt to delete a Value type object ...

33. Efficient Add/Delete Element from Large Collection    forum.hibernate.org

Hi, I really appreciate anyone taking the time to read through this question. I've tried to make it as distilled as possible: I am trying to work out an efficient way of adding / deleting a single item to/from a large collection. The application in question is designed to allow lots of people within an organisation manage their own 'address book', ...

34. no collection snapshot for orphan delete    forum.hibernate.org

35. no collection snapshot for orphan delete    forum.hibernate.org

Hibernate version: 3.2.5 Hibernate throws this: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session) That's the assertion: org.hibernate.AssertionFailure: no collection snapshot for orphan delete Can someone put me on the right track to figure it out? What does it mean: 'no collection snapshot for orphan delete' ? ...

36. dereferenced collection with cascade=all-delete-orphan    forum.hibernate.org

Newbie Joined: Tue Dec 07, 2004 8:15 pm Posts: 10 Location: Adelaide Australia I am having an issue with a persistent collection becoming unreferenced when all-delete-orphan is set. For the life of me I can't figure out how the collection becomes unreferenced. All I do is to create 3 elements and save them in the database then, from a different session, ...

37. Hibernate Filtered collection and delete-orphan cascading    forum.hibernate.org

A bit more info - here is the collection mapping: Code: ...

38. One shot delete and one to many collections    forum.hibernate.org

Hello, I'm using Hiberate version 3.3.1 and trying to write a very simple one to many mapping where deletes are performed efficiently. I've got a number of mappings and am happy with Hibernate for inserting/selecting/etc., but I'm looking at how to efficiently delete relationship, and failing to find a good example. I have two objects, Application and Event. Application has a ...

39. A collection with cascade="all-delete-orphan".    forum.hibernate.org

I have my domain class defined like this public class MyDomainClass { ................................................. private Set myCollection; MyDomainClass(){ this.myCollection = new HashSet(); } ........ public void setMyCollection(Set myCollection){ if(myCollection != null){ this.myCollection.clear(); this.myCollection.addAll(myCollection); } } ..................................... } In other words , i have implemented the set method so that the the myCollection set is managed correctly and we dont run into the ...