-->
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.  [ 4 posts ] 
Author Message
 Post subject: named sql query - problem with composite-id
PostPosted: Tue Jul 05, 2005 6:14 am 
Newbie

Joined: Tue May 24, 2005 4:49 am
Posts: 2
-Hibernate3-
Hello,
I'm try to perform a named sql-query that returns a bean which is mapped with a composite-id.
For example I have a class Person with name,surname and email.
And [name,surname] is the key of the object.
So I have a class named KeyPerson with 2 attributes : name ans surname.
THen my class Person has 2 attributes:
the keyPerson and email.
-----------------------------------------------------------
So the syntax in my xml file is:
<return alias="person" class="Person">
<return-property name="keyPerson.name" column="DB_NAME"/>
<return-property name="keyPerson.surname" column="DB_SURNAME"/>
<return-property name="email" column="DB_EMAIL"/>
</return>
--------------------------------------------------------------
This doesn't work. I would like to know how to write the return tag?
Do I need to use <return-join> or some special tag?
Is my syntax correct?
Any help is very appreciated.
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 11:28 am 
Beginner
Beginner

Joined: Fri Oct 22, 2004 4:47 pm
Posts: 22
I am on hibernate 2.1.7, and am not familar with the return-property. Here is how I have my composite-id tables setup.


<?xml version="1.0"?>

Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
   
   <class name="com.iws.model.eci.search.Patient" table="PATIENT">
      
      <composite-id>
           <key-property name="punbr" column="PUNBR" type="string" />
           <key-property name="grnbr" column="GRNBR" type="string"/>
           <key-property name="essn" column="ESSN" type="string"/>
           <key-property name="seq" column="SEQ" type="string"/>
       </composite-id>
       
      <property name="lname"
                column="LNAME"
                update="false"
                insert="false"
              type="string"/>
             
      <property name="ftname"
                column="FTNAME"
                update="false"
                insert="false"
              type="string"/>

      <property name="addr1"
                column="ADDR1"
                update="false"
                insert="false"
              type="string"/>
             
      <property name="city"
                column="CITY"
                update="false"
                insert="false"
              type="string"/>             
             
      <property name="state"
                column="STATE"
                update="false"
                insert="false"
              type="string"/>   

      <property name="zip"
                column="ZIP"
                update="false"
                insert="false"
              type="string"/>                        
   </class>
   
</hibernate-mapping>


Maybe you could give it a shot and see if it works in 3. You may want to change the DTD to point to the correct one for version 3.

Paul


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 4:01 pm 
Newbie

Joined: Thu Sep 16, 2004 9:03 am
Posts: 8
See my post:
http://forum.hibernate.org/viewtopic.php?t=942912&start=0&postdays=0&postorder=asc&highlight=

I could never get it to work, I believe it is not supported. I listed the line of code that is causing the problem, and it shouldn't be too hard to fix, I just haven't had the time.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 4:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Code:
<return-property name="keyPerson">
     <return-column name="DB_NAME"/>
     <return-column name="DB_SURNAME"/>
</return-property>


I believe.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.