relationship « Delete « JPA Q&A





1. Workarounds for Hibernate's lack of delete-orphan support for one-to-one and many-to-one relationships?    stackoverflow.com

Hibernate has no support for "delete-orphan" cascading of one-to-one or many-to-one relationships. I recently discovered this, and it's giving me a serious headache. I have a couple classes in ...

2. Hibernate getting on my nerve. Delete question on One To One relationship    stackoverflow.com

I have these classes.

@Entity
@Table(name ="a")
class A{
  private Integer aId;
  private B b;

  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "id_a")
  public Integer getAId() {
return aId;
  ...

3. Hibernate many-to-one relationship delete not working as expected    stackoverflow.com

Hi I have 3 tables as following 1) User has userId 2) UserProductEntitlement has userId and productId and a boolean 3) Product has productId This is my class representation :

@Table(name="User")
class User
{
   @OneToMany(fetch=FetchType.EAGER, ...

4. Hibernate many to many relationship and cascade deletion    stackoverflow.com

Using Hibernate, I have the following classes :

public class Person {

    @ManyToMany(fetch=FetchType.LAZY)
    @Cascade(CascadeType.ALL)
    @JoinTable(name = "person_address", joinColumns = { @JoinColumn(name = "person_id") ...

5. Hibernate: cascade deletion of a many-to-many relationship    coderanch.com

Hello, How do I get Hibernate to delete a many-to-many relation automatically when I have it delete one of the related items? For example: I have two entities (domain objects), let's say Employee and Project. One or more employees can be involved in one or more projects. The domain objects are mapped to the tables EMPLOYEE and PROJECT respectively. A third ...

7. Deleting entities and their relationships    forum.hibernate.org

Ok, cool. Don't use inverse for many-to-many, that makes sense. Now to make it more complicated: EntityA has a Map of EntityB to a component. I want to delete an instance of EntityB. How can I do this? This is a real-world problem for me which I haven't addressed yet. I've been assuming "delete the relationship with JDBC, delete the entity ...

8. delete problem with bidirective many to many relationship    forum.hibernate.org

many to many bidirective relation >>with parent class: >test code: ........ Parent3 pa=new Parent3(); pa.setName("pa"); Parent3 pb=new Parent3(); pb.setName("pb"); Child3 ca=new Child3(); ca.setName("ca"); Child3 cb=new Child3(); cb.setName("cb"); Set childset=new HashSet(); childset.add(ca); childset.add(cb); pa.setMychilds(childset); pb.setMychilds(childset); Set parentset=new HashSet(); parentset.add(pa); parentset.add(pb); ca.setMyparents(parentset); cb.setMyparents(parentset); Session sess1=sessions.openSession(); try{ tx=sess1.beginTransaction(); sess1.save(pa); sess1.save(pb); sess1.flush(); List pl=sess1.find("from Parent3 parent where parent.name=?", "pa",net.sf.hibernate.Hibernate.STRING); Parent3 ...

9. Problem updating/deleting many-to-one relationships    forum.hibernate.org

Hi all and thanks in advance for your help. I dont know if I am doing something bad or simply I think that Hibernate can do things that are not possible. I will try to explain what I am doing: I have one relation (many-to-one) between two tables. My mappings are: FileContent.hbm.xml ...





10. Emulate all-delete-orphan with many-to-one relationship?    forum.hibernate.org

Hello, I'm using Hibernate 2.1.2. Is it possible to emulate the actions of all-delete-orphan with a many-to-one relationship? Specifically, given the following ordered actions (cascade="all" is enabled for the relationship): foo.setBar(b1); session.save(foo); ... later on ... foo.setBar(b2); session.update(foo); I'd like Hibernate to then Delete b1, because it's no longer being referenced by anything. My Bar objects can't be elements, they must ...

11. many-to-many deleting only relationship    forum.hibernate.org

Mapping documents: // Manager // Responsible

12. Hibernate delete the relationship betwen 2 objects on update    forum.hibernate.org

Hibernate version: 2.1.6 Mapping documents: EmisoTarjeta.hbm.xml IDEMISORTARJETA_SQ ...

13. delete when unreferenced in one to many relationship    forum.hibernate.org

Hi, I am using the one-to-many association between 2 classes Device and interface. One device can have many interfaces. The mapping tags for the 2 are shown below. I have inverse set to true and cascade set to all-delete-orphan. I want the interfaces to get automatcally added, updated and deleted when refrenced and derefrenced by device. Add and update are working ...

14. Delete and relationships    forum.hibernate.org

Hibernate version: 3.0.2 (in JBoss 4.0.2) Hello, i'm having some problems when deleting objects (inverse side) that are involved in relationships. Maybe someone could help me out or give me some hints? Suppose i have a one-to-many relationship between Company and Employee. Company is declared as the inverse side and the Employee table contains a Foreign Key to the Company. When ...

15. Delete and relationships    forum.hibernate.org

Hibernate version: 3.0.2 (in JBoss 4.0.2) Hello, i'm having some problems when deleting objects (inverse side) that are involved in relationships. Maybe someone could help me out or give me some hints? Suppose i have a one-to-many relationship between Company and Employee. Company is declared as the inverse side and the Employee table contains a Foreign Key to the Company. When ...

16. Problem with cascading relationships with delete-orphan    forum.hibernate.org

Author Message akreiss Post subject: Problem with cascading relationships with delete-orphan Posted: Mon Oct 31, 2005 10:10 am Newbie Joined: Mon Oct 31, 2005 9:49 am Posts: 2 Hey all, Background: I am using Hibernate in a web site I am building. Just as forewarning, I am also using Spring to manage the session, etc, etc. Because it is ...





18. need help: deleting entry from many-to-many relationship    forum.hibernate.org

I am a bit of a hibernate newbie trying to figure out one thing. I have a standard bidirectional many-to-many association between a user and a device object. I followed the manual for how to do this. When I delete the entry on the inverse end of my association (the device), I get a constraint violation. The associations of my mapping ...

19. deleting many to many relationship    forum.hibernate.org

20. Many-to-many relationship update/delete question    forum.hibernate.org

Hibernate version: 3.1 Name and version of the database you are using: MySql 5 In my *:* relationship of User and Department, a join table (member_dept) is used. In java class, a HashSet is used in both side to represent this bi-directional relationship Since the "inverse=true" can only be on one side, I set it on the Department side and hope ...

21. Deleting object with one-to-many relationship    forum.hibernate.org

Hello, My question is rather abstract but I was wondering why developer should manually remove given object from the associated objects' single- or many-valued properties prior delete? I would like to automate the deletion by crawling all the associated object's collection and remove the current object from there. Have you guys done something like this so you can share opinions/patterns? Thank ...

22. delete cascade problem by many-to-one relationship    forum.hibernate.org

i am getting the same exception, if i try to delete an entity from the side "one" by a many-to-one relationship. First i'll explain the very basic scenario: i have 2 entities, Genre and Movie. Every movie belongs to a genre. many movies can belong to only one genre. so relationship is many-to-one. later after I've added some entity instances to ...

23. Delete problem for one-to-one relationship    forum.hibernate.org

24. cascade delete relationship    forum.hibernate.org

25. One-to-many relationship not updating fks when delete parent    forum.hibernate.org

Hibernate version: 3.2.2 GA Mapping documents: Code:

26. many-to-many: delete the relationship    forum.hibernate.org

27. Delete object with 2 one-to-many relationships    forum.hibernate.org

Hi, I am using Hibernate Core 3.2.6ga. I have a class named Subgroup with 2 one-to-many relationships. Here's my mapping (only the excerpt for the relationships): In my Java ...

28. Deleting just the relationship    forum.hibernate.org

Hibernate version:3.2 Mapping documents: A.hbm.xml B.hbm.xml ...

29. Delete on One to many relationship    forum.hibernate.org

[b] ...