diff --git a/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java b/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java
index c10b319319..cb4313c537 100644
--- a/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java
+++ b/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java
@@ -42,7 +42,7 @@ public class DetachedEntityUnitTest {
assertThatThrownBy(() -> session.persist(detachedPost))
.isInstanceOf(PersistenceException.class)
- .hasMessageContaining("`org.hibernate.PersistentObjectException` to JPA `PersistenceException` : detached entity passed to persist");
+ .hasMessageContaining("detached entity passed to persist: com.baeldung.hibernate.exception.detachedentity.entity.Post");
}
@Test
@@ -71,13 +71,13 @@ public class DetachedEntityUnitTest {
assertThatThrownBy(() -> session.persist(detachedPost))
.isInstanceOf(PersistenceException.class)
- .hasMessageContaining("`org.hibernate.PersistentObjectException` to JPA `PersistenceException` : detached entity passed to persist");
+ .hasMessageContaining("detached entity passed to persist: com.baeldung.hibernate.exception.detachedentity.entity.Post");
}
@Test
public void givenDetachedPost_whenMergeAndPersistComment_thenNoExceptionIsThrown() {
Comment comment = new Comment("nice article!");
- Post mergedPost = (Post) session.merge(detachedPost);
+ Post mergedPost = session.merge(detachedPost);
comment.setPost(mergedPost);
session.persist(comment);
diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java
index 02744c8ee5..86f059c6d7 100644
--- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java
+++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java
@@ -136,9 +136,6 @@ public class GetReferenceH2IntegrationTest {
});
StringBuilder expected = new StringBuilder();
- expected.append("Hibernate: select ");
- expected.append("p1_0.id,g1_0.id,g1_0.name,p1_0.name ");
- expected.append("from Player p1_0 left join Game g1_0 on g1_0.id=p1_0.game_id where p1_0.id=?" + System.lineSeparator());
expected.append("Hibernate: delete from Player where id=?" + System.lineSeparator());
assertEquals(expected.toString(), output.toString());
@@ -161,7 +158,7 @@ public class GetReferenceH2IntegrationTest {
expected.append("Hibernate: select ");
expected.append("p1_0.id,g1_0.id,g1_0.name,p1_0.name ");
expected.append("from Player p1_0 left join Game g1_0 on g1_0.id=p1_0.game_id where p1_0.id=?" + System.lineSeparator());
- expected.append("Hibernate: update Player set game_id=?, name=? where id=?" + System.lineSeparator());
+ expected.append("Hibernate: update Player set game_id=?,name=? where id=?" + System.lineSeparator());
assertEquals(expected.toString(), output.toString());
}
@@ -182,7 +179,7 @@ public class GetReferenceH2IntegrationTest {
expected.append("Hibernate: select ");
expected.append("p1_0.id,g1_0.id,g1_0.name,p1_0.name ");
expected.append("from Player p1_0 left join Game g1_0 on g1_0.id=p1_0.game_id where p1_0.id=?" + System.lineSeparator());
- expected.append("Hibernate: update Player set game_id=?, name=? where id=?" + System.lineSeparator());
+ expected.append("Hibernate: update Player set game_id=?,name=? where id=?" + System.lineSeparator());
assertEquals(expected.toString(), output.toString());
}
diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml
index 71158d1ac8..46ac9b50f1 100644
--- a/persistence-modules/pom.xml
+++ b/persistence-modules/pom.xml
@@ -30,7 +30,7 @@
hibernate-mapping-2
-
+ hibernate-exceptions
hibernate-libraries
hibernate-jpa