我的PostgreSQL版本是10.5。什么是hibernate.version 4.3.8.Final的正确Hibernate方言?请注意,该问题与正确的休眠方言有关。休眠版本可能较旧。
Hibernate org.hibernate.dialect.PostgreSQL95Dialect还是org.hibernate.dialect.PostgreSQL82Dialect?
这是application.properties
#Database related properties
database.driver=com.postgresql.jdbc.Driver
database.url=jdbc:postgresql://localhost:5432/springdb
database.user=postgres
database.password=*****************
#Hibernate related properties
hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.hbm2ddl.auto=update
这是pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.package.spring</groupId>
<artifactId>SpringMVCHibernateCRUD</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>SpringMVCHibernateCRUD Maven Webapp</name>
<url>http://maven.apache.org</url>
<!-- Specifying the Versions of Spring, Hiberante, PostgreSQL etc -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.1.5.RELEASE</spring.version>
<hibernate.version>4.3.8.Final</hibernate.version>
<postgresql.version>9.4.1212.jre6</postgresql.version>
<junit-version>4.12</junit-version>
<servlet-api-version>3.1.0</servlet-api-version>
<jsp-version>2.1</jsp-version>
<jstl-version>1.2</jstl-version>
<java.version>1.10</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<!-- Hibernate 4 dependencies -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!--PostgreSQL Connector -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<!-- Servlet and JSP -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet-api-version}</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>${jsp-version}</version>
<scope>provided</scope>
</dependency>
<!-- JSTL dependency -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>${jstl-version}</version>
</dependency>
<!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>SpringMVCHibernateCRUD</finalName>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<includes>
<include>**/*Tests.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:0)
因为postgresql 10是新的。我认为org.hibernate.dialect.PostgreSQL95Dialect是要走的路。我在这里没有看到任何新的课程。
在搜索时,我看到了https://www.muehlencord.de/wordpress/2018/01/30/hibernate-uuid-issues-postgres-10/。额外信息:尝试坚持使用版本9,直到解决所有10个问题为止。
答案 1 :(得分:0)
对于Postgres 8.2及更高版本,理想的SQL方言是org.hibernate.dialect.PostgreSQL82Dialect,而对于PostgreSQL 9.5及更高版本,理想的SQL方言是org.hibernate.dialect.PostgreSQL95Dialect。由于您的版本是10.5。最好的选择是使用PostgreSQL95Dialect,直到出现更多更新的方言为止。