[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5176?page=c...
]
Stephen Visser edited comment on HHH-5176 at 4/29/10 3:30 PM:
--------------------------------------------------------------
From my understanding the 'column' attribute refers to the
column of the local table that identifies the many-to-one relationship.
'property-ref' is used to specify the foreign-key of the destination table when we
are joining on a column other than the primary key. The result that I'm looking for
in this particular many-to-one relationship is something like:
SELECT ...
FROM COURSE_ENROLMENTS c
JOIN STUDENTS s
ON *s.STUDENT_ID=c.STUDENT_ID*
JOIN PERSONS p
ON s.PERSON_ID=p.PERSON_ID
The c.STUDENT_ID is specified by the 'column' attribute, and the s.STUDENT_ID is
_SUPPOSED_ to be specified by the 'property-ref' attribute. The property-ref
works, but instead of using the alias 's' in the above example, STUDENT_ID is
prefixed by 'p'. I can only assume that this is because in my original mapping,
the <join> tags aren't taken into account.
was (Author: sgv):
From my understanding the 'column' attribute refers to the column of the local
table that identifies the many-to-one relationship. 'property-ref' is used to
specify the foreign-key of the destination table when we are joining on a column other
than the primary key. The result that I'm looking for in this particular many-to-one
relationship is something like:
{quote}
SELECT ...
FROM COURSE_ENROLMENTS c
JOIN STUDENTS s
ON *s.STUDENT_ID=c.STUDENT_ID*
JOIN PERSONS p
ON s.PERSON_ID=p.PERSON_ID
{quote}
The c.STUDENT_ID is specified by the 'column' attribute, and the s.STUDENT_ID is
_SUPPOSED_ to be specified by the 'property-ref' attribute. The property-ref
works, but instead of using the alias 's' in the above example, STUDENT_ID is
prefixed by 'p'. I can only assume that this is because in my original mapping,
the <join> tags aren't taken into account.
property-ref doesn't work when property is inside join tags of
destination mapping
----------------------------------------------------------------------------------
Key: HHH-5176
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5176
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Final
Environment: mapping
Reporter: Stephen Visser
My legacy system requires that I have a join in the mappings to fully specify.
Here is the mapping of the entity.
{quote}
<hibernate-mapping>
<class name="Student" table="PERSONS"
lazy="false">
<id name="personID" column="PERSON_ID"/>
<property name="lastName" column="LEGAL_SURNAME" />
<property name="firstName" column="LEGAL_FIRST_NAME"
/>
<property name="birthDate" column="DATE_OF_BIRTH" />
<join table="STUDENTS">
<key column="PERSON_ID"/>
<property name="studentID" column="STUDENT_ID"
unique="true" />
</join>
</class>
</hibernate-mapping>
{quote}
However, when I reference the entity in another mapping:
{code}
<hibernate-mapping>
<class name="Enrolment" table="COURSE_ENROLLMENTS"
lazy="false">
<id name="enrolmentID" column="course_enrollment_id"
/>
<many-to-one name="student" column="student_id"
class="Student" lazy="false" property-ref="studentID"/>
</class>
</hibernate-mapping>
{code}
The studentID property in the Student mapping is assumed to be in the PERSONS table (when
in fact it is in the STUDENTS table since it's inside the join tags). This results in
the alias of the PERSONS table being prepended to the STUDENT_ID column.
When using the property-ref attribute, it should be determined if the referenced property
is inside any join tags. If it is, the correct table alias should be inferred.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira