JPA,MappedSuperclass,Column ID不能接受NULL

时间:2015-01-16 15:15:13

标签: java jpa persistence derby mappedsuperclass

我有像Customer,Request等表格,每个都有ID字段; 我现在有一个摘要 相反,@ MappedSuperclass有

@Id @GeneratedValue private Long id

字段,所有表都用它扩展 @AttributeOverride(name="id", column=@Column(name="ID_CUSTOMER")。但现在,当我尝试将客户添加到表中时,我遇到异常:列ID_Customer无法接受Null值。 当每个表都有自己的id字段时,一切正常。 怎么了? 感谢

@MappedSuperclass
public abstract class GeneralEntity implements Serializable,Cloneable{

@Id
@GeneratedValue
@Column(name = "ID")
private Long id;

@Column(name = "CREATED",nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date created;

@Column(name = "MODIFIED")
@Temporal(TemporalType.TIMESTAMP)
private Date modified;
//getters,setters 

@Entity
@Table(name = "CUSTOMER")
@AttributeOverrides({
@AttributeOverride(name = "id", column = @Column(name="ID_CUSTOMER")),
@AttributeOverride(name="created",  column=@Column(name="CUSTOMER_REGISTERED",nullable = false))
})
public class Customer extends GeneralEntity{

//    @Column(name = "ID_CUSTOMER")
//    @Id
//    @GeneratedValue
//    private Long id;

@Column(name = "CUSTOMER_EMAIL", nullable = false, length = 25, unique = true, updatable = true)
private String email;

@Column(name="CUSTOMER_PASSWORD", nullable = false)
private String password;
//getters setters

0 个答案:

没有答案