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: Returning component values in native SQL Queries
PostPosted: Mon Oct 24, 2005 4:43 pm 
Newbie

Joined: Tue Oct 18, 2005 2:49 pm
Posts: 13
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2x

This is a question about using native SQL queries. Has anyone encountered this?
I have a user class with a component for address class. The address data however is in the user table.

<hibernate-mapping>
<class name="User"
table="USER" >
<id name="UserId" column="FRANCHISE_ID">
<generator class="increment"></generator>
</id>
<property name="firstname" column="USER_FIRST NAME" />
<property name="lastname" column="USER_LAST_NAME" />
<component name="address"
class="com.edmunds.localsearch.model.Address">
<property name="street" type="string" column="STREET"></property>
<property name="city" type="string" column="CITY"></property>
</component>
</class>
<sql-query name="findUser">
<return alias="user" class="User"/>
<![CDATA[ SELECT
user.USER_FIRST NAME as {user.firstname},
user.USER_LAST_NAME as {user.lastname} ,
user.STREET as {user.street} ,
user.CITY as {user.city}
FROM USER user ]]>
</sql-query>
</hibernate-mapping>

For a very specific reason i need to use a native SQL query here.
Is there a way to retrieve the component properties from this SQL query.
Obviously {user.street} is incorrect here. I've also tried {user.address.street}, {address.street} etc.
I've tried all possible combinations but it seems you can retrieve only the direct properties using SQL.
I cannot have a mapping for address as there is no id or association here.

Any ideas?
Thanx in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 12:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
user.address.street should work here. if it doesn't then it is a bug which has been fixed in H3

_________________
Max
Don't forget to rate


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.