我有代码
@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class AbstractModel implements Serializable, Comparable<AbstractModel> {
private static final long serialVersionUID = -4479726024447228668L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idgen")
private Long id;
...
@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class AbstractHistoricModel extends AbstractModel {
private static final long serialVersionUID = -3596885940998632065L;
@Column(name = "pblc_id")
...
@Entity
@SequenceGenerator(initialValue = 0, name = "idgen", sequenceName = "abstract_claim_type_seq")
@XmlAccessorType(XmlAccessType.FIELD)
public class AbstractClaimType extends AbstractHistoricModel {
private static final long serialVersionUID = -3840541568639732203L;
@Column(name = "nam")
private String name;
public AbstractClaimType() { super(); }
@Field
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
...
@Entity
@Table("retr_clm_mthd")
@SequenceGenerator….
@FieldModel
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@AttributeOverride(name="nam", column=@Column(name="retr_clm_mthd_nam", length=255))
public class Retrospective extends AbstractClaimType {
...
当我在内存中创建数据库进行测试时
2013-04-11 14:15:28,445 ERROR (org.hibernate.tool.hbm2ddl.SchemaExport:org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:386)) - HHH000231: Schema export unsuccessful
org.hibernate.tool.hbm2ddl.ImportScriptException: Error during statement execution (file: '/import.sql')
Caused by: java.sql.SQLException: Column not found: RETR_CLM_MTHD_NAM in statement
我看一下scriptdb,有
CREATE MEMORY TABLE RETR_CLM_MTHD(….,NAM VARCHAR(255),….)
为什么不
retr_clm_mthd_nam
?怎么了?
最佳答案
您在超类中没有任何名为“ nam”的属性。您有一个名为“名称”的名称:
private String name;
关于java - @AttributeOverride不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15959369/