-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: mapping a field as a query
PostPosted: Mon Jun 25, 2012 9:17 pm 
Newbie

Joined: Thu May 03, 2012 9:15 am
Posts: 1
I am not sure if this can be done in JPA. I have a query that will always be executed. I can execute in the DAO and set the results as a field. For example, Product entity doesn't have an attribute Offer in the database. But a list of Offers, is retrieved and set for that entity. So that I can say:

Code:
List<Offer> offers = myProduct.getOffers() ;


Currently, I run a complex sql native query to get offers for that Product, and call

Code:
myProduct.setOffers(retrievedOffers) ;


It will be nice to learn how to do it (if possible) using mapping. For example :
Code:
   <attributes>
         <one-to-many name="offers" fetch="LAZY" mapped-by="product_id">
       <!-- Some code here to map  offers to the result of a query -->
         </one-to-many>
      </attributes>


The query is complex and done with SQL.

Thank you.


Some expert can answer this question in a minute. What is going on ? I see a lot of hibernate experts on this forum !


Last edited by m123 on Tue Jun 26, 2012 3:10 pm, edited 1 time in total.

Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.