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: @CollectionOfElements and @OnDelete
PostPosted: Fri Jan 05, 2007 5:55 pm 
Newbie

Joined: Tue Nov 28, 2006 2:37 pm
Posts: 7
Is there any way to configure a @CollectionOfElements association so that SchemaExport will generate "on delete cascade" for the FK constraint on the associated table?

For example:

@CollectionOfElements
@JoinTable(
name="multistring_values",
joinColumns = @JoinColumn(name="attributeid")
)
@Column(name="stringvalue", length=2048)
@OnDelete(action=OnDeleteAction.CASCADE)
public Set<String> getValue() {
return this.value;
}

This results in "only inverse one-to-many associations may use on-delete="cascade"" error message. Ideally I want the associated rows in "multistring_values" table to be removed when the entity containing the collection assocation is removed (without having hibernate issue a separate sql delete).

-Randy


Top
 Profile  
 
 Post subject: Re: @CollectionOfElements and @OnDelete
PostPosted: Wed Feb 17, 2010 9:17 am 
Regular
Regular

Joined: Thu Jun 08, 2006 5:32 pm
Posts: 52
I have the same problem.
Is it possible to define cascade for a @CollectionOfElements via annotations?

I have the following situation (only an example):
Code:
@Entity
public class Person {
   // ...
   @CollectionOfElements(fetch = FetchType.LAZY)
   private Map<Pet, Integer> pets; // Key: Pet, Value: amount
   // ...


All Pets should be removed when the Person will be removed.
Thanks :)

Best regards
QStorm

_________________
http://nocxsville.myminicity.com/


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.