Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.2
Code:
create table tb1(
dbid1 int not null,
dbid2 int not null,
value1 int ,
primary key(dbid1,dbid2)
)
create table tb2(
dbid1 int not null,
dbid2 int not null,
value3 int ,
primary key(dbid1,dbid2,vlaue3)
)
ALTER TABLE tb2 ADD
CONSTRAINT FK_tb2 FOREIGN KEY
(
dbid1,dbid2
) REFERENCES tb1(
dbid1,dbid2
)
GO
tb1-tb2 is one-to-many。
<class name="Tb1Bean" table="tb1">
<composite-id >
<key-property name = "dbid1" column = "dbid1" type="java.lang.Integer"/>
<key-property name = "dbid2" column = "dbid2" type="java.lang.Integer"/>
</composite-id>
<property name="value1" column="value1" type="java.lang.Integer"/>
<set name="tb2List" table="tb2" cascade="all" order-by="value3 asc">
<key column="dbid1" not-null="true" />
<key column="dbid2" not-null="true" />
<one-to-many class="Tb2Bean" />
</set>
</class>
<class name="Tb2Bean" table="tb2">
<composite-id >
<key-property name = "dbid1" column = "dbid1" type="java.lang.Integer"/>
<key-property name = "dbid2" column = "dbid2" type="java.lang.Integer"/>
<key-property name = "value3" column = "value3" type="java.lang.Integer"/>
</composite-id>
</class>
the <set> is bad format ,two <key> is not allowed.
how to??