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: Error in HQL query that SELECTs instances mixed with scalars
PostPosted: Thu May 24, 2007 12:41 am 
Newbie

Joined: Thu May 24, 2007 12:13 am
Posts: 2
Imagine a simple ONE-2-ONE association from Car-->Engine

Car has a scalar property e.g Model ( String )

If the HQL selects:
Select car.Engine, car.Model from Car as car
--> returns null for the retreived association i.e Engine ( car.Engine), but correct value for the Model scalar property


This is incorrect expected behaviour, especially if our HQL contains certain fields from an particular Entity( e.g Car) , and also the entire associated entity( e.g Engine).

We are not using lazy-loading ( lazy=false ) and the generated SQL appears to be fine, and is returning results

However, If I modify the HQL to return complete instances Car and Engine i .e
Select car.Engine, car from Car as car
-->This works as expected -returns values for both instances Engine and Car


There are JIRA issues that relate to something similar:
HHH-1794 - HQL query (list) that SELECTs instances mixed with scalars returns NULLs (instance mappings are in a one-to-one relation)

HHH-2473 - fetch="join" and property-ref

My mappings for easy reference:
CAR
<hibernate-mapping package="domain"
default-cascade="merge">

<class name="Car" table="OS_CAR">

<id name="Id" column="ID" type="string">
<generator class="uuid"/>
</id>


<property name="Model" type="string" column="MODEL" />

<one-to-one name="Engine" lazy="false" cascade="merge, delete"/>


</class>

</hibernate-mapping>

AND
ENGINE
<hibernate-mapping package="domain"
default-cascade="merge">

<class name="Engine" table="OS_ENGINE">

<id name="Id" column="ID">
<generator class="foreign">
<param name="property">Car</param>
</generator>
</id>


<one-to-one name="Car" constrained="true" lazy="false" foreign-key="FK_CAR_ENGINE"/>

</class>

</hibernate-mapping>


Hibernate version 3.2.3

Database: MySQL


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.