我有一個使用鑑別器列的JPA實體。但是我需要將鑑別器的價值作爲實體的一個領域。我怎麼這樣。如果我創建一個鑑別列我會在部署時以下錯誤的匹配方法:獲取鑑別器列的值
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.example.PortEntity column: type (should be mapped with insert="false" update="false")
實體定義:
@Entity(name="Port")
@DiscriminatorColumn(name="type",
discriminatorType=DiscriminatorType.STRING,
length=10)
@DiscriminatorValue(value="port")
@Table(name="vPorts")
@XmlRootElement(name="port")
public class PortEntity {
...
@Column(name="type", length=20, insert=false, update="false")
@XmlAttribute(name="type")
public String getType() { ... }
public void setType(String newType) {... }
...
@Entity(name="SeaPort")
@DiscriminatorValue(value="seaport")
@XmlRootElement(name="seaport")
public static class Sea
extends PortEntity { ... }
@Entity(name="AirPort")
@DiscriminatorValue(value="seaport")
@XmlRootElement(name="seaport")
public static class Air
extends PortEntity { ... }
}
非常感謝。這個項目早已過去,但知識總是有用的。 – Dobbo 2015-06-11 18:03:23