-->
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.  [ 3 posts ] 
Author Message
 Post subject: @AssociationOverride for @Where annotation
PostPosted: Fri May 11, 2007 4:16 pm 
Beginner
Beginner

Joined: Wed Apr 18, 2007 1:44 pm
Posts: 27
Hi folks,

can this be done? I have a @MappedSuperclass with a persistent collection which is intended to be filtered by different @Where clauses at its subclasses. But I can't see how to specify the filter clauses below in the hierarchy.

TIA
Cheers,
Carlos


Top
 Profile  
 
 Post subject: Need help with Hibernate annotations
PostPosted: Fri May 18, 2007 5:18 am 
Newbie

Joined: Fri May 18, 2007 5:13 am
Posts: 1
Location: India
Hi,

I am facing similar kind of problem with @Where. Have you found out a way to resolve this problem?

thanks,
Ravi


Top
 Profile  
 
 Post subject: Re: Need help with Hibernate annotations
PostPosted: Sat May 19, 2007 1:24 pm 
Beginner
Beginner

Joined: Wed Apr 18, 2007 1:44 pm
Posts: 27
jeeravi wrote:
I am facing similar kind of problem with @Where. Have you found out a way to resolve this problem?


What I do just for now is to define an abstract getter for the field in the superclass, and define the field itself and its mapping annotations in every concrete subclass. It's not perfect, as you can't reuse the annotations. But anyway, all the logic on top of the collections is inherited from the abstract superclass. Of course, you must define the abstract getter too:

public abstract class Superclass {

protected abstract List<Child> internalGetChildren();

public void addChild(Child child) {
internalGetChildren().add(child);
child.setParent(this);
}

public void removeChild(Child child) { .... }

public List<Child> getChildren() { ... }

public double getChildrenValueAverage() { ... }
.....
}

public class Subclass1 extends Superclass {
@OneToMany(mappedBy="parent")
@Where(....)
List<Child> children;

protected List<Child> internalGetChildren() { return children; }
}

public class Subclass2 extends Superclass {
@OneToMany(mappedBy="parent")
@Where(....)
List<Child> children;

protected List<Child> internalGetChildren() { return children; }
}

Cheers,
Carlos


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