Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 环境、液化和冬眠_Spring_Maven_Spring Boot_Liquibase_Nhibernate Envers - Fatal编程技术网

Spring 环境、液化和冬眠

Spring 环境、液化和冬眠,spring,maven,spring-boot,liquibase,nhibernate-envers,Spring,Maven,Spring Boot,Liquibase,Nhibernate Envers,我正在寻找一种动态创建审计表模式的方法(在hibernate中使用DDL=none) 目前,我使用liquibase创建表的模式。配置是使用带有DB2数据库的hibernate(spring boot应用程序)。目前,我对envers表的insert语句有错误(因为不存在任何表): 我已经阅读了Hibernate 4中的liquibase Hibernate插件,除了标签之外,不需要任何特殊配置就可以创建表 在pom.xml文件中 以下是我的配置: pom.xml <plu

我正在寻找一种动态创建审计表模式的方法(在hibernate中使用DDL=none)

目前,我使用liquibase创建表的模式。配置是使用带有DB2数据库的hibernate(spring boot应用程序)。目前,我对envers表的insert语句有错误(因为不存在任何表):

我已经阅读了Hibernate 4中的liquibase Hibernate插件,除了标签
之外,不需要任何特殊配置就可以创建表 在pom.xml文件中

以下是我的配置:

pom.xml

        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>${liquibase.version}</version>
            <configuration>
                <changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
                <diffChangeLogFile>target/${maven.build.timestamp}_liquibase_changelog.xml</diffChangeLogFile>
                <driver>com.ibm.db2.jcc.DB2Driver</driver>
                <url>jdbc:db2://localhost:50000/test</url>
                <username>${db.username}</username>
                <password>test</password>
                <referenceUrl>hibernate:spring:de.test.tool.domain?dialect=org.hibernate.dialect.DB2Dialect</referenceUrl>
                <verbose>true</verbose>
                <logging>debug</logging>
                <propertyFileWillOverride>false</propertyFileWillOverride>
                <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
                <contexts>${liquibase.contexts}</contexts>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.javassist</groupId>
                    <artifactId>javassist</artifactId>
                    <version>3.18.2-GA</version>
                </dependency>
                <dependency>
                    <groupId>org.liquibase.ext</groupId>
                    <artifactId>liquibase-hibernate4</artifactId>
                    <version>${liquibase-hibernate4.version}</version>
                </dependency>

                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-data-jpa</artifactId>
                    <version>${project.parent.version}</version>
                </dependency>
            </dependencies>
        </plugin>
应用程序属性

# ===============================
# = JPA / HIBERNATE
# ===============================

# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager).

# Show or not log for each sql query
spring.jpa.show-sql=true


# Hibernate ddl auto (create, create-drop, update, none): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
spring.jpa.hibernate.ddl-auto=none
spring.jpa.generate-ddl=false

# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DB2Dialect
# Naming strategy
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy

# ===============================
# = DATA SOURCE
# ===============================

# Set here configurations for the database connection

# Connection url for the database "netgloo_blog"

spring.datasource.driverClassName=com.ibm.db2.jcc.DB2Driver
spring.datasource.url=jdbc:localhost:50000/test
# password
spring.datasource.password=test

# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT values(1)
package de.test.tool.domain;

import org.hibernate.envers.Audited;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

    /**
     * Test-Entitaet.
     */
    @Entity
    @Audited
    @Table(name="CALCULATEVALUE")
    @EntityListeners(AuditingEntityListener.class)
    public class CalculateValue {

        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue
        private Long id;

        @Column(nullable = false, name="OWN_VALUE")
        private int ownValue = 0;

        @Column(nullable = false, name="CALCULATION_DATE_LONG")
        private long calculationDateLong = 0;

        public int getOwnValue() {
            return ownValue;
        }

        public void setOwnValue(int ownValue) {
            this.ownValue = ownValue;
        }


        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }

        public long getCalculationDateLong() {
            return calculationDateLong;
        }

        public void setCalculationDateLong(long calculationDateLong) {
            this.calculationDateLong = calculationDateLong;
        }
# ===============================
# = JPA / HIBERNATE
# ===============================

# Use spring.jpa.properties.* for Hibernate native properties (the prefix is
# stripped before adding them to the entity manager).

# Show or not log for each sql query
spring.jpa.show-sql=true


# Hibernate ddl auto (create, create-drop, update, none): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
spring.jpa.hibernate.ddl-auto=none
spring.jpa.generate-ddl=false

# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DB2Dialect
# Naming strategy
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy

# ===============================
# = DATA SOURCE
# ===============================

# Set here configurations for the database connection

# Connection url for the database "netgloo_blog"

spring.datasource.driverClassName=com.ibm.db2.jcc.DB2Driver
spring.datasource.url=jdbc:localhost:50000/test
# password
spring.datasource.password=test

# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT values(1)