aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Defining custom query for properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Defining custom query for properties" Watch "Defining custom query for properties" New topic
Author

Defining custom query for properties

Alejandro Dominguez
Greenhorn

Joined: Jun 01, 2007
Posts: 28
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 ]

Alejandro<br /> <br />SCJP 5 (SAI)
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
a bit costly, but you can certainly do it with code inside the accessor,
an annotation might be convenient, but it's not necessary,


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Alejandro Dominguez
Greenhorn

Joined: Jun 01, 2007
Posts: 28
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Defining custom query for properties
 
Similar Threads
Read-only view entities
Hibernate Querys.
Value List Handle Pattern
HQL: entity/entities in set of entities
building a search feature in my application, what is the best approach