• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hard coding a "where" clause for JPA

 
Michael Remijan
Author
Ranch Hand
Posts: 131
7
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using JPA and what I need to know is if it's possible to use the persistence annotations to hard code a "where" clause. For example, something like "where active='y'"
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that what javax.persistence.Query all about?
 
Michael Remijan
Author
Ranch Hand
Posts: 131
7
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well no, I don't think so. Not in this case. What I'm talking about is creating a relationship with another bean/table. A simple example is something like a Person object which contains a Telephone object. Suppose the database design of the telephone data contains many rows for a person but only one which is active='Y'. I need to somehow setup the 1-1 relationship between the two beans with this extra active='Y'. I guess I can do it in a query but I'd rather avoid that if possible.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you looking for the Hibernate specific @Filter? See if this helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic