java - 升级到版本 5 后,无法在休眠中将蛇盒设为默认值
问题描述
我们最近将休眠升级到了版本 5。以下是 POM 文件中存在的版本。我们正在使用 Spring roo
我的 sql 版本是 -> mysql Ver 14.14 Distrib 5.7.28,适用于使用 EditLine 包装器的 macos10.14 (x86_64)
<aspectj.version>1.8.9</aspectj.version>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<roo.version>1.3.2.RELEASE</roo.version>
<slf4j.version>1.6.4</slf4j.version>
<spring.version>5.2.8.RELEASE</spring.version>
<surefire.version>2.22.0</surefire.version>
<cxf.version>2.2.6</cxf.version>
<junit-version>4.13</junit-version>
**<hibernate-version>5.4.18.Final</hibernate-version>**
我们正在使用这个插件和配置来生成一个 sql 文件,它为我们创建模式并更新本地表
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.31</version>
</dependency>
</dependencies>
<!-- common configuration shared by all executions -->
<configuration>
<driver>${db.driver}</driver>
<url>${db.jdbcUrl}</url>
<username>${db.user}</username>
<password>${db.password}</password>
<!--all executions are ignored if -Dmaven.test.skip=true -->
<skip>${maven.test.skip}</skip>
</configuration>
<executions>
<execution>
<id>drop-db-before-test-if-any</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<!-- need another database to drop the targeted one -->
<url>${db.bootstrapUrl}</url>
<autocommit>true</autocommit>
<sqlCommand>drop database ${db.database}</sqlCommand>
<!-- ignore error when database is not avaiable -->
<onError>continue</onError>
</configuration>
</execution>
<execution>
<id>create-db</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<url>${db.bootstrapUrl}</url>
<!-- no transaction -->
<autocommit>true</autocommit>
<sqlCommand>create database ${db.database}</sqlCommand>
</configuration>
</execution>
**<execution>
<id>create-schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>true</autocommit>
<orderFile>descending</orderFile>
<fileset>
<basedir>${basedir}</basedir>
<includes>
<include>src/test/sql/quartz_mysql_innodb.sql</include>
<include>target/generated-resources/sql/ddl/auto/mysql5innodb.sql</include>**
<include>src/test/sql/test_acl_seed_data.sql</include>
</includes>
</fileset>
</configuration>
</execution>
我们也在使用下面的配置,它使用 insert.xml 文件来创建架构
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dbunit-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<!--jar file that has the jdbc driver -->
**<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.31</version>
</dependency>
</dependencies>**
<!-- common configurations -->
<configuration>
<driver>${db.driver}</driver>
<url>${db.jdbcUrl}</url>
<username>${db.user}</username>
<password>${db.password}</password>
<dataTypeFactoryName>org.dbunit.ext.mysql.MySqlDataTypeFactory</dataTypeFactoryName>
</configuration>
<executions>
<execution>
<id>clean-insert</id>
<phase>test-compile</phase>
<goals>
<goal>operation</goal>
</goals>
**<configuration>
<type>CLEAN_INSERT</type>
<src>src/test/data/insert.xml</src>
</configuration>**
</execution>
<execution>
<id>export</id>
<phase>test</phase>
<goals>
<goal>export</goal>
</goals>
<!-- specific configurations -->
<configuration>
<format>xml</format>
<dest>target/dbunit/export.xml</dest>
</configuration>
</execution>
</executions>
</plugin>
Insert.xml 示例
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<table name="table_name">
<column>id</column>
<column>action_name</column>
<column>active_flag</column>
<column>version</column>
<column>class_name</column>
<column>created_at</column>
<column>description</column>
<column>job_parameters</column>
<column>name</column>
<column>queue</column>
<column>updated_at</column>
<row>
<value>1</value>
<value/>
<value>true</value>
<value>0</value>
<value/>
<value><![CDATA[2011-01-01 00:00:00.0]]></value>
<value><![CDATA[Loads data into Data Warehouse from operational database]]></value>
<value>{"run_job_name":"job_process_main"}</value>
<value><![CDATA[Warehouse Data Load]]></value>
<value>etl</value>
<value><![CDATA[2011-01-01 00:00:00.0]]></value>
</row>
</table>
Persistance.xml(休眠配置)
<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<property name="hibernate.connection.charSet" value="UTF-8"/>
<property name="hibernate.id.new_generator_mappings" value="false"/>
</properties>
</persistence-unit>
</persistence>
之前我们用过这个
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
由于更新后这不起作用,我们根据物理和隐式命名策略的其他答案尝试了许多替代方案,并且还覆盖了手动物理命名策略。但它总是采用默认的命名策略。
请帮忙
解决方案
推荐阅读
- python - Python 中的 FFT 计算错误的频谱
- mysql - sql insert 语句的两种方式在性能方面有什么区别吗?
- sql-server-data-tools - 无法在 Visual Studio 2013 中加载 Microsoft SQL Server Data Tools
- python - Fuzzy Wuzzy 匹配名称
- php - weird behaviour when $_POST-ing text which includes "Location:"
- flutter - 我在 Flutter 中有一个错误,我不知道如何修复
- excel - VBA 图片分辨率
- ios - Html2pdf.js (ekoopmans) 工具生成任何 iOS 设备中的所有空白页,当我们生成 20 多页 PDF 时,一些最后一页数据丢失
- java - 找不到 SyncConfiguration(或 Realm 的等效类)
- virtual - Visual Studio 16.8.4 创建的 IIS 虚拟目录