Hi. I am trying to map a many-to-one from A.this to B.that without much luck.
The tables look like this:
Code:
create table A (
id int not null,
this int not null,
);
CREATE UNIQUE INDEX A_KEY ON A (id);
create table B (
id2 varchar(30) not null,
that int not null,
);
CREATE UNIQUE INDEX B_KEY ON B (id2);
And the mapping files look like this:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 17-Feb-2011 15:54:36 by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>
<class name="A" table="A" schema="dbo">
<cache usage="read-only"/>
<id name="id" type="int">
<column name="id" />
<generator class="assigned"/>
</id>
<property name="this" type="int" insert="false" update="false">
<column name="this" not-null="true" />
</property>
<many-to-one name="B" class="B" column="this" />
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 17-Feb-2011 19:45:39 by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>
<class name="B" table="B" schema="dbo">
<cache usage="read-only"/>
<id name="id2" type="string">
<column name="id2" length="30" />
<generator class="assigned"></generator>
</id>
<property name="that" type="int">
<column name="that" not-null="true" />
</property>
</class>
</hibernate-mapping>
(The names have been changed so the fact there is a property called 'this' does not matter)
I know the mapping above is incorrect but how would I map it correctly?
How would I tell hibernate that A.this column maps to B.that? THere doesnt seem to be an obvious way to do this.
I have looked at docs and examples but it is still not clear how this can be mapped.
Any help would be greatly appreciated.
Thanks in advance.