• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

User's Vases Hibernate Problem

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The situation is Users have Vases. But the vases maybe broken.

The tables look like this


The mappings look like this


But I need to have methods getBrokenVases() and getGoodVases() in the User class. Also for these calls I don't want all Vases come to the web server from the DB but only broken or good ones (for performance reasons). What approach should I take.

Approach 1 : I could think of is I should have two Sets in class User and use a "where" attribute of mapping <set>. But is it true that in "where" attribute I can only put in native sql. How do I use HSQL ?

Approach 2 : Use filters. This seems like a new approach. But here too can I only use native sql.

One other problem I faced was the generated SQL won't execute because in the where clause I used table names. But else where Hibernate used aliases. So the query wouldn't run unless I use alias in where clause. So how do I know what alias Hibernate generates? Is this only a problem with Derby db.

Please suggest a good solution to this problem. I would prefer to use HSQL.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about inheritance, create subclasses of Vase, and then use the boolean as the discrimintor value. I will let you find out how to do that on your own, as this is a coursework homework that you are doing. Good Luck. Your thoughts aren't off either, but I think inheritence is the easiest, once you get past the terms.

Mark
 
What is that? Is that a mongol hoarde? Can we fend them off with this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic