mrzhouhibernate wrote:
create table TAA(
FAID int,
FAID2 int,
FaName varchar(50),
CONSTRAINT PK_AA PRIMARY KEY (FAID,FAID2)
)
create table TBB(
FBID int,
FAID int,
FAID2 int,
FbName varchar(50),
constraint PK_BB primary key (FBID),
CONSTRAINT FK_B_A FOREIGN KEY (FAID,fAId2) REFERENCES TAA(FAID,faId2)
)
I have two tables, use composite key, there is a problem in the table TBB mapping XML
the table TAA is right.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="cn.miw">
<class name="Taa" table="TAA" >
<meta attribute="sync-DAO">false</meta>
<composite-id name="Id" class="TAAPK">
<key-property name="Faid2" column="FAID2" type="integer" />
<key-property name="Faid" column="FAID" type="integer" />
</composite-id>
<property
name="FaName" column="FaName" type="string" not-null="false" length="50" />
</class>
</hibernate-mapping>
there is a problem in the table TBB
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="cn.miw">
<class name="TBB" table="TBB" >
<meta attribute="sync-DAO">false</meta>
<id name="Id" type="integer" column="FBID" >
<generator class="sequence"/>
</id>
<property name="FbName" column="FbName" type="string" not-null="false" length="50" />
<many-to-one name="Faid2" column="FAID2" class="Taa" not-null="false" ></many-to-one>
<many-to-one name="Faid" column="FAID" class="Taa" not-null="false" ></many-to-one>
</class>
</hibernate-mapping>
the code in red is wrong.
how can I do mapping the TBB???
and how can build the set in TAA?