java - 用于插入学生详细信息的休眠应用程序
问题描述
我有一个按以下方式建模的现有数据库:
学生 - 学生 ID(整数)、学生姓名(字符串)、性别(字符串)
CollegeStudent - 学期(弦乐),年级(弦乐)
学生 - 学期(字符串),排名(整数)
我想为上面的类图开发一个 Hibernate 应用程序来插入学生的详细信息。注意:插入 2 个 Student 类型的对象、2 个 CollegeStudent 的对象和 2 个 School Student 的对象。
现在我正在为这个现有数据库创建休眠实体。我在创建从学生到大学生和学生的多对多映射时遇到了奇怪的问题。有什么建议吗?
在此处输入代码`
import javax.persistence.*;
import org.hibernate.annotations.Table;
import javax.persistence.GeneratedValue;
@Entity
@Table(name="STUDENT")
public class Student {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int Student_id;
private String Student_name,Student_gender;
@ManyToOne(cascade = CascadeType.ALL)
private CollegeStudent collegeStudent;
public CollegeStudent getCollegeStudent() {
return CollegeStudent;
}
public void setCollegeStudent(CollegeStudent collegeStudent) {
this.CollegeStudent = collegeStudent;
}
@ManyToOne(cascade = CascadeType.ALL)
private SchoolStudent schoolStudent;
public SchoolStudent getSchoolStudent() {
return SchoolStudent;
}
解决方案
推荐阅读
- angular - 分配外部指令属性的角度语法?
- ionic-framework - Ionic SQLite 插件在删除时总是抛出异常
- php - 如何显示总数 年龄组
- wordpress - Wordpress 多站点的单独域名
- java - 带有多个答案的 Arraylist android studio 测验应用程序
- haskell - 如何最轻松地将具有大量导入(许多合格)的大型 Haskell 文件分解为较小的文件?
- php - 使用 google drive api 将照片上传到免费存储
- php - 迭代每一行并获取计数 php mysql
- javascript - 如何正确地从 PHP 发送 JSON 数据?
- laravel - 具有多个角色的 laravel 用户具有多个权限