【发布时间】:2016-05-22 03:07:39
【问题描述】:
我可以在 Embeddable 类中添加多对一映射吗? 在这里,它试图直接获取值 jobCategoryMast。 这是一个映射对象。
抛出异常 org.postgresql.util.PSQLException: ERROR: 列 jobvaccina0_.jobcategorymast 不存在
@Entity
@Table(name="job_vac",schema="cis")
@SuppressWarnings("serial")
public class JobVacc implements java.io.Serializable {
// Fields
@Column(name="default", length=1)
private String default;
@EmbeddedId
private JobVaccPK jobVaccinationPK;
public JobVacc(){
}
//getters and setters
}
// JobVaccPK 类
@Embeddable
@SuppressWarnings("serial")
public class JobVaccPK implements Serializable{
/*@Column(name = "job_category_id")
private Long jobCategoryId;*/
private JobCategoryMast jobCategoryMast;
@Column(name = "vaccination_id")
private Long vaccId;
@Column(name = "screening_type_id")
private Long screeningTypeId;
/**
* @return the jobCategoryMast
*/
public JobCategoryMast getJobCategoryMast() {
return jobCategoryMast;
}
/**
* @param jobCategoryMast the jobCategoryMast to set
*/
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="job_category_id")
public void setJobCategoryMast(JobCategoryMast jobCategoryMast) {
this.jobCategoryMast = jobCategoryMast;
}
//other setters and getters
【问题讨论】:
标签: spring spring-mvc jpa hibernate-mapping