-->
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.  [ 6 posts ] 
Author Message
 Post subject: CascadeType.ALL/PERSIST ignored
PostPosted: Fri Jul 06, 2007 5:36 pm 
Beginner
Beginner

Joined: Tue Mar 15, 2005 5:04 am
Posts: 26
Hi All,

Hibernate version: 3.2.3.ga

Hibernate-Annotations version: 3.3.0.ga

Hibernate-Commons-Annotations version: 3.0.0.ga


I am having a small problem with OneToMany assosiations. Small, because actually they work. But what does not work is the CascadeType.ALL or CascadeType.PERSIST.
I want the owning Object to Persist the Collections Objects when saved.
My Annotation Mapping is this:

PARENT:
Code:
public abstract class AccountGroup extends Account {

   @OneToMany(cascade={CascadeType.ALL}, mappedBy="parent")
   protected Set<Account> accounts = new HashSet<Account>();
   
...

}

CHILD:

Code:
public abstract class Account{

...
   
   @ManyToOne(cascade={CascadeType.ALL})
   @JoinColumn(name="parent_account_id")
   private Account parent;
   
...

}


The Actual Accounts are subclasses of this Class. As I Allready wrote. This mapping does work except of the CascadeTypes. I Want to save the Parent and then have the childs being persisted too.

Can anyone give me a hint, why this does not work? From my Point of view hibernate ist simply ignoring what i am telling it to do ;-/

Thx,
Alexander


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 11, 2007 11:38 am 
Beginner
Beginner

Joined: Tue Mar 15, 2005 5:04 am
Posts: 26
Hi,
I still have not found any solution. Does really nobody have any clue if there is anything else i have to take care of but the CascadeType?

Thx,
Alexander


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 12, 2007 6:43 am 
Beginner
Beginner

Joined: Tue Mar 15, 2005 5:04 am
Posts: 26
Hi,
i still have the problem. Can anyone send me his examplecode where cascading works when putting the annotations to the attributes and not the accessing methods? I cannot see any failures. What am I missing?


Thx,
Alexaner


Top
 Profile  
 
 Post subject: My guess is that the problem is with - "mappedBy="
PostPosted: Tue Aug 14, 2007 3:01 am 
Regular
Regular

Joined: Wed May 02, 2007 2:42 pm
Posts: 101
mappedBy , means that this side of the relation is not manage the relation, so when you save the parent it is not save also the child.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 4:12 pm 
Newbie

Joined: Sat Dec 09, 2006 8:14 pm
Posts: 4
Do not know whether you have solved this meanwhile... but I had similar "problem" when the class stored in hash set had bad equals and hashCode methods implementation.

Check that yours Account class does not have this trouble.

HTH,
dale


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 12:32 pm 
Newbie

Joined: Sat May 26, 2007 8:18 am
Posts: 9
when putting the annotations to the attributes and not the accessing methods? I cannot see any failures. What am I missing?




-------------------------------------------------------------
惨~刚给老板骂,做虚拟主机客服给投诉,跳槽算了不做域名。哪位GGJJ介绍薪水高责任少上班时间短公司MM多的好job。


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