• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Defining custom query for properties

 
Alejandro Dominguez
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,
I'm trying to map my beans to a *very* weird and complicated database schema and the annotations are just not enough some times; is it possible to define custom queries for accessing the properties (at this point I'm interested in read only behavior).

I'd like something like

@Entity
{ ...

@MyCustomQuery(....)
public Set getSomething() {}
}

If I'm not mistaken, Hibernate 2.1 allowed a similar definition in the xml.

I'd really like to avoid having to add the query code inside my entity...

Regards
[ January 21, 2008: Message edited by: Alejandro Dominguez ]
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a bit costly, but you can certainly do it with code inside the accessor,
an annotation might be convenient, but it's not necessary,
 
Alejandro Dominguez
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see; the logical next question is then: can I inject a PersistenContext into a @Entity?
I tried doing so, but it is always null...

Regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic