Merge pull request #591 from bdragan/master

Upgrade to Hibernate 5.2.2.Final
This commit is contained in:
Zeger Hendrikse 2016-08-10 00:35:53 +02:00 committed by GitHub
commit 51ab817796
3 changed files with 18 additions and 11 deletions

View File

@ -189,13 +189,13 @@
<properties> <properties>
<!-- Spring --> <!-- Spring -->
<org.springframework.version>4.2.5.RELEASE</org.springframework.version> <org.springframework.version>4.3.2.RELEASE</org.springframework.version>
<javassist.version>3.20.0-GA</javassist.version> <javassist.version>3.20.0-GA</javassist.version>
<!-- persistence --> <!-- persistence -->
<hibernate.version>4.3.11.Final</hibernate.version> <hibernate.version>5.2.2.Final</hibernate.version>
<mysql-connector-java.version>5.1.38</mysql-connector-java.version> <mysql-connector-java.version>5.1.38</mysql-connector-java.version>
<spring-data-jpa.version>1.8.2.RELEASE</spring-data-jpa.version> <spring-data-jpa.version>1.10.2.RELEASE</spring-data-jpa.version>
<h2.version>1.4.192</h2.version> <h2.version>1.4.192</h2.version>
<!-- logging --> <!-- logging -->

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
<persistence-unit name="punit" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="punit">
<class>org.baeldung.persistence.model.Foo</class> <class>org.baeldung.persistence.model.Foo</class>
<class>org.baeldung.persistence.model.Bar</class> <class>org.baeldung.persistence.model.Bar</class>
<properties> <properties>
@ -9,9 +11,10 @@
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/HIBERTEST"/> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/HIBERTEST"/>
<property name="javax.persistence.ddl-generation" value="drop-and-create-tables"/> <property name="javax.persistence.ddl-generation" value="drop-and-create-tables"/>
<property name="javax.persistence.logging.level" value="INFO"/> <property name="javax.persistence.logging.level" value="INFO"/>
<property name = "hibernate.show_sql" value = "true" /> <property name="hibernate.show_sql" value="true"/>
<property name = "hibernate.cache.use_second_level_cache" value = "false" /> <property name="hibernate.cache.use_second_level_cache" value="false"/>
<property name = "hibernate.cache.use_query_cache" value = "false" /> <property name="hibernate.cache.use_query_cache" value="false"/>
</properties> </properties>
</persistence-unit> </persistence-unit>
</persistence> </persistence>

View File

@ -2,6 +2,7 @@ package org.baeldung.persistence.service;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import org.baeldung.config.ProductConfig; import org.baeldung.config.ProductConfig;
import org.baeldung.config.UserConfig; import org.baeldung.config.UserConfig;
@ -57,10 +58,13 @@ public class JpaMultipleDBIntegrationTest {
user2.setAge(10); user2.setAge(10);
try { try {
user2 = userRepository.save(user2); user2 = userRepository.save(user2);
userRepository.flush();
fail("DataIntegrityViolationException should be thrown!");
} catch (final DataIntegrityViolationException e) { } catch (final DataIntegrityViolationException e) {
// Expected
} catch (final Exception e) {
fail("DataIntegrityViolationException should be thrown, instead got: " + e);
} }
assertNull(userRepository.findOne(user2.getId()));
} }
@Test @Test