-->
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.  [ 4 posts ] 
Author Message
 Post subject: Can one ON DELETE CASCADE with a @CollectionOfElements?
PostPosted: Tue Feb 20, 2007 3:55 pm 
Newbie

Joined: Sun Feb 13, 2005 5:00 pm
Posts: 5
In an Entity containing

Code:
private Set<String> witticisms = new HashSet<String>();

@CollectionOfElements
public Set<String> getWitticisms()
{
    return witticisms;
}


is there any way to ask Hibernate to emit DDL that causes the foreign key declaration in the collection table to include ON CASCADE DELETE, as one can with an association between entities, as in

Code:
@OneToMany(mappedBy = "parent")
@OnDelete(action = OnDeleteAction.CASCADE)
public Set<Child> getKid()
{
    return kid;
}

_________________
--
Jonathan Feinberg jdf@pobox.com Medford, MA
http://MrFeinberg.com/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 8:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
did you try? Does it work?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 21, 2007 10:57 am 
Newbie

Joined: Sun Feb 13, 2005 5:00 pm
Posts: 5
emmanuel wrote:
did you try? Does it work?


Yes, I tried before posting. The result is

Code:
org.hibernate.MappingException: only inverse one-to-many associations may use on-delete="cascade": my.org.Raconteur.witticisms
   at org.hibernate.mapping.Collection.validate(Collection.java:265)
   at org.hibernate.mapping.Set.validate(Set.java:19)
   at org.hibernate.cfg.Configuration.validate(Configuration.java:1106)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
   at my.org.MyHibernateUtil.<clinit>(MyHibernateUtil.java:39)
   ... 23 more


The point of my question was to determine whether there's any way to get Hibernate to emit ON DELETE CASCADE for a @CollectionOfElements, just as it will do so for an inverse association.

If it is impossible to do so, then I will create an entity to contain the String, and associate them. I would consider it a kluge to have to do so, hence my question. The question was asked in good faith.

_________________
--
Jonathan Feinberg jdf@pobox.com Medford, MA
http://MrFeinberg.com/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 6:57 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
open a JIRA issue, but it won't be high priority. I think it has to do with messing up with hibernate's entity lifecycle

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.