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>();

 

 

 

 

你可能感兴趣的:(Hibernate)