aspose file tools*
The moose likes Object Relational Mapping and the fly likes @JoinColumn Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "@JoinColumn Question" Watch "@JoinColumn Question" New topic
Author

@JoinColumn Question

Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
Can I specify a where condition with @JoinColumn or is there any other annotation for this purpose?
Suppose I have User and Subjects objects, 1 to many relationship. I have 2 Sets - passedSubjects and failedSubjects based on column subjectStatus.
How can I load subjects into passedSubjects where subjectStatus="passed"

@JoinColumn(name = "userid", referencedColumnName="userid", table="UserSUBJECTs")
public Set<Subject> getPassedSubjects() {
return subjects;
}


-Varun -
(My Blog) - Online Certifications - Webner Solutions
Angel Taveras
Ranch Hand

Joined: Nov 13, 2008
Posts: 84

Hello you can use the where annotation for that, you could look for an example http://www.hibernate.org/hib_docs/annotations/reference/en/html/entity.html#entity-hibspec-collection.

regards
Varun Chopra
Ranch Hand

Joined: Jul 10, 2008
Posts: 211
Thanks but is there any similar annotation in JPA, I see this in Hibernate, not in JPA?
Angel Taveras
Ranch Hand

Joined: Nov 13, 2008
Posts: 84

i really don't know. But for another EntityManager maybe there it's a similar approach
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @JoinColumn Question
 
Similar Threads
Composite Key
Meet-in-the-middle mapping question
Can a class be mapped to a table and be Embeddable at the same time?
Id not availble in lazy loaded associate objects
ManyToMany assoicate delete join table entry