-->
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: cannot use property-ref in <key> under <join>
PostPosted: Thu May 07, 2009 12:53 am 
Newbie

Joined: Thu May 07, 2009 12:39 am
Posts: 2
Hi,

I am trying to join a parent table (to add a property) into my entity using the <join>. I understand <join> works the other way around but to join it using the entity's FK is using the property-ref attribute for the <key>. Applying property-ref seems to be useless to the SQL generated. Does anyone know what is wrong or is there a bug in nhibernate that I am not aware of (in regard to using <key> under <join>)

I tried NHibernate 2.0 and the latest NHibernate 2.1.0Alpha2
I am using NHibernate.Mapping.Attribute

The SQL generated is :
SELECT this_.ID as ID7_0_,
...,
this_1_.POLICY_NAME as POLICY2_8_0_ FROM BPAS_Base_mod.dbo.CS_USER_INFO this_ left outer join BPAS_Base_mod.dbo.CS_ACCOUNT_POLICY this_1_ on this_.ID=this_1_.ID WHERE this_.USER_NAME = @p0; @p0 = 'super'

The bold section in the SQL should have been POLICY_ID because I used property-ref in my <key>.

The schema is as such (NOTE: I am using NHibernate.Mapping.Attribute and this is just a generated schema):

<?xml version="1.0" encoding="utf-8"?>
<!--Generated by NHibernate.Mapping.Attributes on 2009-05-07 11:59:50Z.-->
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Consolsys.Domain.Impl.CsUserInfo, Consolsys.Domain" lazy="true" table="CS_USER_INFO">
<id name="Id" column="ID" type="long" unsaved-value="0">
<generator class="identity" />
</id>
....
<property name="PolicyId" column="POLICY_ID" not-null="true" />
<join table="CS_ACCOUNT_POLICY" optional="true">
<key column="ID" property-ref="PolicyId" on-delete="noaction" update="false" />
<property name="PolicyName" column="POLICY_NAME" />
</join>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: cannot use property-ref in <key> under <join>
PostPosted: Wed May 13, 2009 11:38 pm 
Newbie

Joined: Thu May 07, 2009 12:39 am
Posts: 2
Apparently this is still an open case in nhibernate that needs to be resolve.

http://nhjira.koah.net/browse/NH-1452

I do hope they fix it coz I believe it is kinda important for some cases..


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.