微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么 hibernate 在测试扩展实体时说 class 没有 id?

如何解决为什么 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.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?