见另一贴(100分)
http://community.csdn.net/Expert/topic/4454/4454095.xml?temp=.1961634
http://community.csdn.net/Expert/topic/4454/4454095.xml?temp=.1961634
解决方案 »
- 哪些人用tomcat
- Spring环境下怎么把一个变量放在ServletContext里
- 求解:关于JSTL的forEach嵌套循环之index不为零的问题,望高人指点
- HIBERNATE调用有两个返回值的oracle存储过程怎么做
- 怎么在.jsp页面中加入视频
- 请问一个关于Hibernate查询的奇怪问题
- struts文件下载,不提示保存对话框就直接下载了
- struts跳转问题
- 马上结在线等:关于hash中的元素的中文打印问题
- 我要用java获取数据库最近12个月的数据怎么写
- 关于CRM系统中的客户管理要实现什么功能
- ********************************问题的关键就在这里!*************************
<composite-id name="id" class="EmployeeEduKey">
<key-many-to-one name="employee(的对象名)" column="empid" class="Employee"/>
<key-many-to-one name="edu(对象名)" column="eduid" class="eduid所属的类(Edu)"/>
</composite-id>
<property name="username" column="eduname" type="java.lang.String" />
<!-- 其他属性略-->
</class>public Class EmployeeEduKey{
private Employee employee;
private Edu edu;
..
}
public Class Employee{
private EmployeeEduKey id;
...
}
private EmployeeEduKey id;
...
}
tx.commit(); //提交事物
tx.rollback(); //回滚事务其实,hibernate只是对jdbc做了轻量的封状,最终的实现,还是通过jdbc的事务管理来实现的,不过用户不必了解那么多,使用hibernate提供的接口就可以。
至于,多主建,一般都是用主建类来实现。
--------------------------------------------
public class StudentCourse implements Serializable {
private StudentCoursePK comp_id;
private Float grade;
......
--------------------------------------------
package eqzhou.mis.studentCourse;import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;public class StudentCoursePK implements Serializable {
private String studentId;
private String courseId;
public StudentCoursePK() {
}
public String getCourseId() {
return courseId;
}
public String getStudentId() {
return studentId;
}
public void setCourseId(String courseId) {
this.courseId = courseId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
} public boolean equals(Object other) {
if ( !(other instanceof StudentCoursePK) ) return false;
StudentCoursePK castOther = (StudentCoursePK) other;
return new EqualsBuilder()
.append(this.getStudentId(), castOther.getStudentId())
.append(this.getCourseId(),castOther.getCourseId())
.isEquals();
} public int hashCode() {
return new HashCodeBuilder()
.append(this.getStudentId())
.append(this.getCourseId())
.toHashCode();
}}
---------------------------------------------<class
name="eqzhou.mis.studentCourse.StudentCourse"
table="student_course"
> <composite-id name="comp_id" class="eqzhou.mis.studentCourse.StudentCoursePK">
<key-property
name="studentId"
column="STUDENT_ID"
type="java.lang.String"
length="8"
>
</key-property>
<key-property
name="courseId"
column="COURSE_ID"
type="java.lang.String"
length="3"
>
</key-property>
</composite-id> ............
---------------------------------------------和你问题相关的部分内容,已经铁了出来,你看下。
UP