【发布时间】:2011-05-13 05:10:54
【问题描述】:
您好,我有以下型号:
@Entity
class Flight{
private Airport airportFrom;
private Airport airportTo;
@OneToOne(fetch=FetchType.LAZY,optional=false)
public Airport getAirportFrom(){
return this.airportFrom;
}
@OneToOne(fetch=FetchType.LAZY,optional=false)
public Airport getAirportTo(){
return this.airportTo;
}
}
@Entity
class Airport{
private Integer airportId;
@Id
public Integer getAirportId(){
this.airportId;
}
}
我收到了这个错误:
org.hibernate.MappingException: Repeated column in mapping for entity: model.entities.Flight column: airportId (should be mapped with insert="false" update="false")
【问题讨论】:
-
我已经尝试在每个@OneToOne 下添加@Column(name="airportFrom) 和@Column(name="airportTo"),但出现此错误:“@column(s) not allowed在@onetoone 属性上"
标签: java hibernate-mapping hibernate3