• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

@JoinColumn Question

 
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;
}
 
Ranch Hand
Posts: 84
Hibernate Eclipse IDE 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
Hibernate Eclipse IDE 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!