@AttributeOverride不起作用

时间:2013-04-11 21:41:07

标签: java hibernate jpa

我有代码

@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? 有什么问题?

1 个答案:

答案 0 :(得分:1)

超类中没有任何名为“nam”的属性。你有一个名为“名字”:

private String name;