-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Use of @OnDelete(...CASCADE) with a OneToMany in JPA
PostPosted: Fri May 20, 2011 9:40 am 
Newbie

Joined: Fri Feb 15, 2008 10:48 am
Posts: 3
Hi everybody,

we have a very simple case

Code:
public class Building...
    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
    @JoinColumn(name = "ID_BUILDING", nullable = false)
    List<Address> address = ...

public class Address...



and pretty much all the relations in our modell are like this one, that is fine, but...

In only one use case when we have to delete one huge root record Hibernate generates a big amount of DELETE.

We tryed to modify the mapping to use the @OnDelete(action=OnDeleteAction.CASCADE) this way

Code:
public class Building...
    @OneToMany(mappedBy = "building", cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @OnDelete(action=OnDeleteAction.CASCADE)
    List<Address> address = ...

public class Address...
    @ManyToOne
    @JoinColumn(name="ID_BUILDING", insertable=false, updatable=false)
    Building building;



but now the owner of the relationship is Address and that changes the way Hibernate generates its requests.
We are very close to release the application in production and we cannot do so deep changes.

Is it a way to use the @OnDelete(action=OnDeleteAction.CASCADE) but not with an inverse relation (aka inverse=false) with JPA?

Thank you for your help.


Top
 Profile  
 
 Post subject: Re: Use of @OnDelete(...CASCADE) with a OneToMany in JPA
PostPosted: Thu Jun 30, 2011 4:30 am 
Beginner
Beginner

Joined: Fri Dec 04, 2009 9:37 am
Posts: 34
Hihi,

I am forcing at the same issue:
viewtopic.php?f=1&t=1011651&p=2446465&hilit=OnDelete+JPA#p2446465

let us know if any solution is available.

rgs Andre


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.