• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using @Where with joins

 
John Boby
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, in the end I will no use view. I am gonna just add an extra column to my place and tag table. I will have rewrite all the queries to include a statement like "AND state=my.package.State.ACTIVE" which is quite ugly and brings me an other question...

I don't know if I should create a new thread for this but, while I'm doing my refactoring, all my queries now looks like this

@Query("SELECT p FROM Place WHERE p.name=:name AND p.state=my.package.State.ACTIVE");
public List<Place> getPlaces();

I know that with Hibernate there is a way to put a "@Where (clause="state='ACTIVE?"); on the Entity (so i can remove that AND condition). This works well on simply query like the one above
But when I do join... it doesn't work like I would like. This is my Entity schema.




Now my question would be how can make this statement ONLY return the places and tags that are ACTIVE ?



Is this possible? Or will I have to write the query Explicitly ?

Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic