为什么 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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...