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.  [ 7 posts ] 
Author Message
 Post subject: Property-ref not working???
PostPosted: Tue May 02, 2006 5:29 pm 
Newbie

Joined: Tue May 02, 2006 5:16 pm
Posts: 3
Hello, I am new to Hibernate and I am using Hibernate 3.1.2 with a legacy database system. I am trying to use the <join> element:

<hibernate-mapping>
<class name="UserActivity" table "UserActivity">
<id name="id" column="activity_id">

......

</id>

......

<property name="userActivity" column="activity_type_cd" type="int"/>

......

<join table="UserRole">
<key column="role_cd" prop-ref="activity_type_cd"/>
......

</join>
</class>
</hibernate-mapping>


However, the join condition is still including
where UserRole.role_cd=UserActivity.activity_id instead of
where UserRole.role_cd=UserActivity.activity_type_cd. What should I be doing differently? Any help is greatly appreciated - thanks.


Last edited by oawofolu on Thu May 04, 2006 2:34 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed May 03, 2006 9:54 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
property-ref (not prop-ref, though I presume that you have it right in your mapping file, otherwise it wouldn't parse) takes the name of a property as its parameter, not the name of a column. Use 'property-ref="userActivity"'.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 10:53 am 
Newbie

Joined: Tue May 02, 2006 5:16 pm
Posts: 3
Thanks,

I did have property-ref="userActivity" (pardon the typo)

But it's still joining on the primary key of UserActivity (the "id" property) instead of the userActivity property?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 2:27 pm 
Newbie

Joined: Thu May 04, 2006 2:20 pm
Posts: 1
Having the same problem here. Trying different values for 'column' 'foreign-key' and 'property-ref' changes the foreign column but not the local one. The join is always

... join ... on siteimpl_0.id=siteimpl_0_1.whatever

[edit]Using hibernate version 3.1.3[/edit]

<class name="SiteImpl"
table="sites">
...
<property name="institutionId"
type="integer"
not-null="true"/>

<join table="institutions">

<key column="id"
property-ref="institutionId"/>

<property name="instState"
type="Hasc"
column="state"
update="false"
insert="false"/>

</join>

</class>


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 7:15 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
daveidmx: the id you've highlighted is the "local" column, affeceted by the column attribute. The "whatever" is the foreign one, affected by property-ref. foreign-key isn't used in this situation (it's for hbm2ddl).

If this is repeatable and reproducable, I'd look in JIRA for it. Maybe it's a known bug.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 08, 2006 1:25 pm 
Newbie

Joined: Mon Jan 24, 2005 4:05 pm
Posts: 5
I'm running into a similar problem, and I believe a similar problem exists as an entry in JIRA

http://opensource.atlassian.com/project ... e/HHH-1348

I haven't seen any official response to this and there hasn't been any action on the bug in JIRA. I found one JIRA issue that was closed because another issue was already open, but I can't find the original.

Is there any good way to get around this?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 08, 2006 7:01 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Switch from <join> to <one-to-one> or <many-to-one unique="true">, then use delegation from your "main" object to the associated one. Not pretty, but possibly more correct, and certianly more efficient, than <join>.

_________________
Code tags are your friend. Know them and use them.


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