Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@JoinColumn Question

 
Varun Chopra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
}
 
Angel Taveras
Ranch Hand
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks but is there any similar annotation in JPA, I see this in Hibernate, not in JPA?
 
Angel Taveras
Ranch Hand
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i really don't know. But for another EntityManager maybe there it's a similar approach
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic