-->
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.  [ 2 posts ] 
Author Message
 Post subject: return-property inside return-join tag is ignored?
PostPosted: Fri Jan 07, 2011 6:39 pm 
Regular
Regular

Joined: Thu Oct 19, 2006 12:07 pm
Posts: 75
Using hibernate 3.6.0.Final I noticed the following problem.
If I have a query defined like this:
Code:
<sql-query name="myQuery1"  >
      <return  alias="st" class="Star">
         <return-property name="id"  column="key_one" />
         <return-property name="name"  column="nick" />
         <return-property name="mass"  column="pounds" />
      </return>
      <return-join alias="wp" property="st.planets">
         <return-property name="id" column="ignored_by_hibernate"/>
<!--         <return-property name="id" column="also_ignored"/>-->
         <return-property name="myStar" column="I can write whatever I want here"/>
      </return-join>
select
     st.id as key_one,
     st.name as nick,
     st.mass as pounds ,
     wp.my_star_id as my4_1_0__,
     wp.id as id0__,
     wp.id as id2_1_,
... (rest is below)

It appears the return-property tags inside the return-join tag are not recognized. No matter what values I put for name or column, hibernate will use its own values form column names, like id0_ , id2_1_, etc.

I discovered that in <return> if I misspell a name, like this: <return-property name="ifoood" column="key_one" />
then hibernate will use a column name like "id1_0_" for that column.
So I guess I have the name attributes wrong in the return-join tag.
I tried "id", "wp.id", "st.wp.id", but nothing is recognized.

Any idea what is wrong?

Here is the mapping:
Code:
    <class name="Star" table="STARS">
        <id name="id" column="id"><generator class="sequence"/></id>
        <property name="name"/>
        <property name="mass"/>

   <set name="planets" inverse="true">
      <key column="my_star_id" />
      <one-to-many class="Planet" />
      <loader query-ref="customLoader"/>
   </set>
    </class>
    <class name="Planet">
        <id name="id" column="id"><generator class="sequence"/></id>
        <property name="name"/>
        <many-to-one name="myStar" column="my_star_id"/>
    </class>

The complete SQL in above named query is:
Code:
select
     st.id as key_one,
     st.name as nick,
     st.mass as pounds ,
     wp.my_star_id as my4_1_0__,
     wp.id as id0__,
     wp.id as id2_1_,
     wp.name as name2_1_,
     wp.my_star_id as my4_2_1_
   from
        STARS st
    left outer join
        Planet wp
            on st.id=wp.my_star_id
    where
        st.name like :namePattern


Top
 Profile  
 
 Post subject: Re: return-property inside return-join tag is ignored?
PostPosted: Fri Jan 07, 2011 7:19 pm 
Regular
Regular

Joined: Thu Oct 19, 2006 12:07 pm
Posts: 75
I also tried load-collection instead of return-join, but it works the same.


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

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.