• 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
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Hibernate: get interface, rather than implementation

 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a object hierarchy that includes both inheritance and and interface implementation. In certain cases, it makes sense for our object model to return an interface, rather than an implementation. However, when we attempt to retrieve, we don't get back any rows (empty resultset). What we see in the generated SQL is that hibernate appends a "1=2" to what would be an otherwise valid SQL query.

Has anyone else run into this before, or can you point me to examples of retrieval via interface? (E.g., getInterfaceA, rather than getClassA.)
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do you retrieve "the interface" ? can you show us some code

since an interface can not be instantiated you can not persist it. you can only get back an object that implements the given interface.

if you've mapped the interfaces and implementation (as an inheritance hierarchy) then you can get back implementations of a given interface trough Criteria or HGL. e.g.


i think best would be if you show some code and the mapping.

and i've never seen hibernate append "where 1 = 2" does not make much sense...

pascal
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic