-->
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: Question about "all-delete-orphan"
PostPosted: Fri Jun 04, 2004 1:36 pm 
Beginner
Beginner

Joined: Fri Nov 28, 2003 11:21 am
Posts: 49
Location: Buenos Aires, Argentina
Hi, I want know the semantic about "cascade = all-delete-orphan". if I have two classes A y B where A has a one-to-many relation with B and this relation have the property "cascade = all-delete-orphan" this means that I could not do [b]a.setBs(new ArrayList())[/b] where [b]a[/b] is an instance of A, that is the collection never must be instanciated. That is correct? because I have 3 classes A, B y C with the following relations: "A one-to-many B" and "B one-to-many C" both with the property "all-delete-orphan" so when I want to access to the collection in A (getBs()) it is never null, but when I want to access the collection in B (getCs()) it is null, but if I put [b]b.setCs(new ArrayList())[/b] the error "You may not dereference a Collection" appears.
Any suggestions? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 1:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Typically collection initialization is taken care of during instance construction.

Code:
public class A {
    ...
    private List bs = new ArrayList();
    ...
}

public class B {
    ...
    private List cs = new ArrayList();
    ...
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 1:58 pm 
Beginner
Beginner

Joined: Fri Nov 28, 2003 11:21 am
Posts: 49
Location: Buenos Aires, Argentina
"Typically collection initialization is taken care of during instance construction. "

it means that I should initiliaze all collections in the constructor as long as these collections have the property "cascade = all- delete- orphan"?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 2:15 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Typically, I do this on all instance-level collections, regardless of whether they are mapped in Hibernate using all-delete-orphan or whether I am even using Hibernate at all. It simply helps not to have to deal with null checks and NPE. But also, because it is consistent and I don't have to worry about how or in what environment this collection property is getting used.


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.