mongodb中document的复合主键申明方式
package yaycrawler.dao.domain; import javax.persistence.*; import java.sql.Blob; @Entity @IdClass(QrtzJobDetailsIds.class) @Table(name = "qrtz_job_details") public class QrtzJobDetails implements java.io.Serializable { /* 现在复合主键(sched_name job_name job_group都需要加上@Id并且需要单独创建类,然后再当前类加上@IdClass(QrtzJobDetailsIds.class) 【QrtzJobDetailsIds自行定义】 ) */ /** 版本号 */ private static final long serialVersionUID = 840552323049001278L; /** schedName */ @Id @Column(name = "sched_name", unique = true, nullable = false, length = 120) private String schedName; /** jobName */ @Id @Column(name = "job_name", unique = true, nullable = false, length = 200) private String jobName; /** jobGroup */ @Id @Column(name = "job_group", unique = true, nullable = false, length = 200) private String jobGroup; /** description */ @Column(name = "description", nullable = true, length = 250) private String description; }
复合主键定义的类
public class QrtzJobDetailsIds implements Serializable{ private static final long serialVersionUID = 7431247025727743159L; public String schedName; public String jobName; public String jobGroup; public QrtzJobDetailsIds() { } public QrtzJobDetailsIds(String schedName, String jobName, String jobGroup) { this.schedName = schedName; this.jobName = jobName; this.jobGroup = jobGroup; } .................. }
人生没有彩排,每天都是现场直播!