hibernate M-N 中间表属性修改问题
问题 一个学生对应多门课 一个课对应多门学生 先要对s_c表中的一个学生打分 怎么办
现有数据库
create table student(
sid varchar(32) not null primary key,
name varchar(10) not null,
age int(2),
tel varchar(11),
grade varchar(4),
sex char(2),
major varchar(20));
create table class(
cid varchar(32) not null primary key,
name varchar(10) not null);
create table s_c(
sid varchar(32) ,
cid varchar(32) ,
score int (3),
FOREIGN KEY (sid) REFERENCES student(sid) ON DELETE CASCADE ,
FOREIGN KEY (cid) REFERENCES class(cid) ON DELETE CASCADE,
primary key(sid,cid));
hibernate 配置文件
class.hbm.xml
<hibernate-mapping>
<class catalog="eol" name="com.chang.hbm.Class" table="class">
<id name="cid" type="string">
<column length="32" name="cid"/>
<generator class="uuid.hex"/>
</id>
<property generated="never" lazy="false" name="name" type="string">
<column length="10" name="name" not-null="true"/>
</property>
<set cascade="all" inverse="false" lazy="false" name="student"
sort="unsorted" table="s_c">
<key>
<column length="32" name="cid" not-null="false"/>
</key>
<many-to-many class="com.chang.hbm.Student" column="sid" unique="false"/>
</set>
student-hbm.xml
<hibernate-mapping>
<class catalog="eol" name="com.chang.hbm.Student" table="student">
<id name="sid" type="string">
<column length="32" name="sid"/>
<generator class="assigned"/>
</id>
<property generated="never" lazy="false" name="name" type="string">
<column length="10" name="name" not-null="true"/>
</property>
<property generated="never" lazy="false" name="age" type="integer">
<column name="age"/>
</property>
<property generated="never" lazy="false" name="tel" type="string">