Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

using @Where with joins

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic