如何解决为什么 hibernate 在测试扩展实体时说 class 没有 id?
我正在尝试建立一个 h2 数据库进行测试。问题是,当我尝试运行测试时,我收到一个错误:ids for this class must be manually assigned before calling save()
,即使超类具有 id。这只是一个糟糕的实体设计还是我的配置有问题?
超类:
@MappedSuperclass
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Data {
@Id
protected Long NB_ID;
protected String FG_STATUS;
@Column(name="FG_ETAT")
protected String FG_ETAT;
protected String LB_ETAT;
getters/setters
子类:
@Entity
@Table(name="ERESIS.ECH_HISExpcOM")
public class CustomerDelivery extends Data{
protected String CD_COM1;
protected Integer NO_LIGNE;
protected String CD_MAT;
protected Double QT_NET;
getters/setters
我的配置:
nav.datasource.url=jdbc:h2:mem:sanders_20180813_nemanja;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
nav.datasource.username=sa
nav.datasource.password=sa
nav.datasource.driver-class-name=org.h2.Driver
nav.datasource.max-idle=2
nav.datasource.min-idle=2
nav.datasource.initial-size=2
nav.jpa.show-sql=true
nav.jpa.hibernate.ddl-auto=create
nav.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgresqlDialect
nav.jpa.properties.connection.CharSet=utf8
nav.jpa.properties.connection.characterEncoding=utf8
nav.jpa.properties.hibernate.connection.useUnicode=true
nut.datasource.url=jdbc:h2:mem:NUTRICIEL_SYNC;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
nut.datasource.username=sa
nut.datasource.password=sa
nut.datasource.driver-class-name=org.h2.Driver
nut.datasource.max-idle=2
nut.datasource.min-idle=2
nut.datasource.initial-size=2
nut.datasource.testOnBorrow=true
#nut.datasource.validationQuery=SELECT 1 FROM DUAL
nut.jpa.show-sql=true
nut.jpa.hibernate.ddl-auto=create
nut.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
nut.jpa.properties.connection.CharSet=utf8
nut.jpa.properties.connection.characterEncoding=utf8
nut.jpa.properties.hibernate.connection.useUnicode=true
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。