我有以下实体类和另一个用于复合主键的类
实体类
@Entity
@Table(name = "PROJECTS")
public class Project {
private Integer SlNo;
private Long projectNo;
private Date projectDate;
@EmbeddedId
ProjectPK projectPK;
主键类
public class ProjectPK implements Serializable {
private Integer SlNo;
@Column(name = "project_no", insertable = false, updatable = false)
private Long projectNo;
public ProjectPK(){
}
// with getters and setters and equals and hashCode implementation
问题是我收到以下异常
:org.hibernate.MappingException:Repeated column in mapping for entity
: test.Project column: projectNo (should be mapped with
insert="false" update="false")
我在Project Entity
课堂上添加了以下内容,但我得到了同样的例外
@Column(name = "project_no", insertable = false, updatable = false)
编辑 1
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> countQ = cb.createQuery(Long.class);
Root<Project> empCount = countQ.from(Project.class);
countQ.select(cb.count(empCount));
TypedQuery<Long> countquery = entityManager.createQuery(countQ);// error in this line