`
bnmnba
  • 浏览: 288887 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

Hibernate @Column(s) not allowed on a @ManyToOne property

 
阅读更多

在写一个自关联的实体时报错:org.hibernate.AnnotationException: @Column(s) not allowed on a @ManyToOne property: pp.entity.Employee.superior

 

	@ManyToOne(targetEntity=Employee.class)
	@Column(nullable=true)
	@JoinColumn(name="superiorId",updatable=false,insertable=false)
	private Employee superior;
	
	@OneToMany(mappedBy="superior")
	@Column(nullable=true)
	private List<Employee> underlings=new ArrayList<Employee>();

 

 更改为:

 

	@ManyToOne(targetEntity=Employee.class)
	//@Column(nullable=true)
	@JoinColumn(name="superiorId",updatable=false,insertable=false,nullable=true)
	private Employee superior;
	
	@OneToMany(mappedBy="superior")
	@Column(nullable=true)
	private List<Employee> underlings=new ArrayList<Employee>();

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics