-->
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.  [ 13 posts ] 
Author Message
 Post subject: property-ref attribute being ignored in join, is this a bug?
PostPosted: Thu Dec 16, 2004 11:30 am 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
The Hibernate 3.0alpha documentation in section 5.1.17 key states the following.

(3) property-ref (optional): Specifies that the foreign key refers to columns that are not the primary key of the orginal table. (Provided for legacy data.)

I want it to join like this,

sectiontim0_.sss_dowid=sectiontim0_1_.sss_dowid

but, instead, it joins like this,

sectiontim0_.sss_timesid=sectiontim0_1_.sss_dowid

i.e. it's still using the primary key from the first table instead of the one that I specified using a property-ref. It does so regardless of whether I specify the property-ref.

Is this a bug?

Also, why do I have to specify a property-ref? i.e. why can't I just specify a column name instead? I would rather specify a column because the column is only needed for the join.

Hibernate version: 3.0alpha

Mapping documents:

<?xml version="1.0"
encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="SectionTime"
table="sss_times"
mutable="false">
<id name="id"
column="sss_timesid">
<generator class="native"/>
</id>
<property name="daysId"
column="sss_dowid"/>

<join table="sss_dow">
<key column="sss_dowid"
property-ref="daysId"/>

<property name="days"
column="name"/>
</join>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

SectionTime st = (SectionTime)s.get(SectionTime.class, 305084);
System.out.println(st);

Full stack trace of any exception that occurs:

No stack trace, the generated SQL just isn't what I'm expecting

Name and version of the database you are using:

Microsoft SQL Server 2000

The generated SQL (show_sql=true):

select sectiontim0_.sss_timesid as sss_time1_0_,
sectiontim0_.sss_dowid as sss_dowid5_0_,
sectiontim0_1_.name as name6_0_
from sss_times sectiontim0_
inner join sss_dow sectiontim0_1_ on sectiontim0_.sss_timesid=sectiontim0_1_.sss_dowid
where sectiontim0_.sss_timesid=?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 20, 2004 11:27 am 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
Can anyone confirm whether this is a bug? I'm planning on submitting a bug report on it...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 02, 2005 12:06 pm 
Newbie

Joined: Thu Feb 10, 2005 6:51 am
Posts: 2
I have also come across this, but as I am just learning Hibernate, I am not confident to comment whether it's me or Hibernate that is the problem.

Can anyone with more experience confirm this?

I am using Hibernate 3.0 RC1.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 3:26 am 
Beginner
Beginner

Joined: Mon Apr 11, 2005 8:37 am
Posts: 22
What happened to this issue? I just came across the same problem (CVS-checkout from Apr. 18) - it still doesn't work. Is it fixed in the 3.0.2 release?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 9:27 am 
Beginner
Beginner

Joined: Mon Apr 11, 2005 8:37 am
Posts: 22
as far as I worked with it by now, the property-ref attribute in <set><key property-ref="..."> works, but not in <join><key property-ref="...">.
Can anybody confirm this or give me an example that works?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 10:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
<join><key property-ref></join> is not yet implemented, and I'm sure you cannot find that used anywhere in the Hibernate docs.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 3:10 am 
Beginner
Beginner

Joined: Mon Apr 11, 2005 8:37 am
Posts: 22
Thanks for the information. It's not in the doc - but in the dtd. I guess your statement applies also to <joined-subclass><key property-ref></joined-subclass> ? Is there a chance to those implemented in the near future?
It would be really helpful, especially when mapping legacy data (with composite db PKs where one attribute needs to be generated - and only with <properties>...</properties> one can define an alternate, composite unique key).


Top
 Profile  
 
 Post subject: yes please implement this sooner rather than later
PostPosted: Mon Jun 13, 2005 4:05 pm 
Newbie

Joined: Mon Mar 21, 2005 5:23 pm
Posts: 4
Location: Beaverton, OR
Gavin,

We ran into this umplemented feature too and would very much like to use it right away. Thanks. -Matt


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 13, 2005 4:13 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
So, if you need it "right away", a patch will be gladly accepted.

Or, if you don't want to write a patch, contact sales@jboss.com.

Otherwise, this will get done when it gets done. It is not currently in scope for HB3.1.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 10:07 am 
Newbie

Joined: Wed Jun 15, 2005 8:00 am
Posts: 16
Location: Munich, Germany
Also ran into this.

Is there a recommended work-around?

Greetings,
M


Top
 Profile  
 
 Post subject: Did anyone patch this as yet
PostPosted: Wed Apr 19, 2006 6:00 am 
Newbie

Joined: Wed Apr 19, 2006 5:35 am
Posts: 7
did anyone as yet patch or find a workaround for this problem? I am keen to join two tables and use the property-ref attribute to do so as it saves me from inflating several classes for 3 properties.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 19, 2006 6:39 am 
Newbie

Joined: Wed Jun 15, 2005 8:00 am
Posts: 16
Location: Munich, Germany
Not that I know of. I carefully refactored the ER model.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 04, 2006 1:27 am 
Newbie

Joined: Thu Mar 30, 2006 9:21 pm
Posts: 11
Hello everyone, I read this topic with interested when I encountered this problem the other day. I have worked out a hack which aoppears to fix it. But I am new to Hibernate so I may be stuffing something else up. Anyway if you want to see my xml files, and the hack I've come up with, check out this topichttp://forum.hibernate.org/viewtopic.php?t=958943

I would be interested to know if this is a viable fix.

ciao
Derek

_________________
Derek Clarkson
Analyst Programmer
Aegeon Pty Ltd
Melbourne Australia


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