[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3324) Support many-to-one multiple -property-ref

Sonix Legend (JIRA) noreply at atlassian.com
Mon Jun 2 23:51:33 EDT 2008


Support many-to-one multiple -property-ref
------------------------------------------

                 Key: HHH-3324
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3324
             Project: Hibernate3
          Issue Type: Improvement
          Components: core
         Environment: Hibernate 3.2.6ga, Oracle 9.2
            Reporter: Sonix Legend


I have a problem in my current project.
For example,
I have a table which name is "A".
create table A
(
...
     varchar2(10) a1,
     varchar2(10) a2,
...
);
And another table which name is "B".
create table B
(
...
      varchar2(10) b1 primary key,
      varchar2(10) b2 primary key,
...
);
alter table B add constraint PK_B primary key (b1, b2);
Then I generated two hibernate mapping files by hibernate tools.
A.hbm.xml
...
<class name="A" table="A">
...
     <property name="a1" type="string">
          <column name="a1" length="10" />
     </property>
     <property name="a2" type="string">
          <column name="a2" length="10" />
     </property>
...
</class>
...
B.hbm.xml
...
<class name="B" table="B">
...
     <composite-id name="id" class="C">
          <key-property name="b1" type="string">
               <column name="b1" length="10" />
          </key-property>
          <key-property name="b2" type="string">
               <column name="b2" length="10" />
          </key-property>
     </composite-id>
...
</class>
...
Now I wanted A "left outer join" B, so I added a "many-to-one" element into "A.hbm.xml".
<many-to-one name="b" class="B">
     <column name="a1" />
     <column name="a2" />
</many-to-one>
And I added a "one-to-many" element into "B.hbm.xml".
<set name="a">
     <key>
          <column name="a1" />
          <column name="a2" />
     </key>
     <one-to-many class="A" />
</set>
I writed a HQL.
"select a, b from A as a left outer join a.b as b where a.a1 = 'test1' and a.a2 = 'test2' and (b is null or b.b1 = 'test3')"
When the hibernate loads the mapping files, there was not an error.
But when the query executes, it report a error "column ambiguous defined".
I got the sql that generated from hql by p6spy.
select ... a_0.a1, a_0.a2, a_0.a1, a_0.a2, ... b_0.b1, b_0.b2, ... from ...
So the error wake me up to the "a1" and "a2" columns had repeated in the "A.hbm.xml" file.
The "many-to-one" element only have a "property-ref" attribute. But the "a1" and "a2" fields are used at the "where" condition or other tables associate, and I can't modify the "A" table because other systems uses it.
I hope you can resolve the problem with any method.
I'm apologize for my English. So sorry.
Thanks

-- 
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list