联合外键作主键 @EmbeddwdId
来源:互联网 发布:淘宝运营教程视频下载 编辑:程序博客网 时间:2024/05/19 09:01
嵌入类:
- package com.dlnu.model;
- import java.io.Serializable;
- import javax.persistence.Embeddable;
- import javax.persistence.JoinColumn;
- import javax.persistence.ManyToOne;
- @Embeddable
- public class Name implements Serializable {
- private static final long serialVersionUID = 1L;
- private Course course;
- private Student student;
- public Name() {
- }
- public Name(Course course, Student student) {
- this.course = course;
- this.student = student;
- }
- @ManyToOne
- @JoinColumn(name = "courseId", referencedColumnName = "cno",nullable=true)
- public Course getCourse() {
- return course;
- }
- @ManyToOne
- @JoinColumn(name = "studentId", referencedColumnName = "sno")
- public Student getStudent() {
- return student;
- }
- public void setStudent(Student student) {
- this.student = student;
- }
- public void setCourse(Course course) {
- this.course = course;
- }
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj.getClass() == Name.class) {
- Name target = (Name) obj;
- if (target.getCourse().equals(course)
- && target.getStudent().equals(student)) {
- return true;
- }
- }
- return false;
- }
- public int hashCode() {
- return course.hashCode() + student.hashCode() * 17;
- }
- }
实体类:
- package com.dlnu.model;
- import javax.persistence.EmbeddedId;
- import javax.persistence.Entity;
- @Entity
- public class SC {
- private Name name;
- private Double grade;
- public Double getGrade() {
- return grade;
- }
- @EmbeddedId
- public Name getName() {
- return name;
- }
- public void setGrade(Double grade) {
- this.grade = grade;
- }
- public void setName(Name name) {
- this.name = name;
- }
- }
- 联合外键作主键 @EmbeddwdId
- 联合外键作主键 @EmbeddwdId
- 联合主键
- 联合主键
- 联合主键
- 联合主键
- 联合主键
- 联合主键
- 联合主键
- 联合主键
- 联合主键
- 联合主键 复合主键
- sql 设置主键 联合主键
- 复合主键与联合主键
- 复合主键与联合主键
- Hibernate 中的联合主键
- hibernate 联合主键
- hibernate操作联合主键
- 一些有用的知识
- linux下IPTABLES配置详解
- SQL学习笔记(二)
- ClassLoader.loadClass() throws java.lang.ClassNotFoundException
- SeaJS 里版本号和时间戳管理的最佳实践
- 联合外键作主键 @EmbeddwdId
- java.lang.NoSuchMethodException
- 自己写的,跳转到xx页面后,自动触发特定button的click事件
- 未能加载文件或程序集 Microsoft.ReportViewer.ProcessingObjectModel, Version=10.0.0.0...错误问题的解决
- Hadoop Namenode HA方案比较
- 从配置文件里读取数据,实现多数据库连接
- maven 常用命令
- 【dp+数论】PKU-3420-Quad Tiling
- smarty 缓存技术