我正在尝试建立一个 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