-->
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: bag composite-element from subselect
PostPosted: Fri Dec 09, 2011 4:07 pm 
Newbie

Joined: Fri Dec 09, 2011 4:02 pm
Posts: 1
I have a query I want to be able to use to populate a composite-element property of a class. I have created this:
Code:
<bag name="Relationships">
      <subselect>
        select count(RelationID) as Relations, Relationship, EntityID from rcs.tblRelation_Link group by Relationship, EntityID
      </subselect>
      <key column="EntityID" />
      <composite-element class="Relationship">
        <many-to-one class="Lookup" name="RelationType" column="Relationship" />
        <property name="Count" type="int" column="Relations" />
      </composite-element>
    </bag>


Which generates a query that looks like this:
Code:
SELECT relationsh0_.EntityID     as EntityID0_,
       relationsh0_.Relationship as Relation2_0_,
       relationsh0_.Relations    as Relations0_
FROM   Relationships relationsh0_
WHERE  relationsh0_.EntityID = '[i]guidvalue[/i]'


So clearly this is not the way to do what I am trying to do. Does anyone have a suggestion of how to use a query to populate elements like this short of creating a view on the database side? I would ideally like to keep everything in the app so it is obvious where it is coming from.

I may not have explained this completely so please do let me know if you I can clarify anything!

Thanks!


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.