JAVA-20464 Fix failing tests in hibernate-exceptions module (#13885)

* JAVA-20464 Fix failing tests in hibernate-exceptions module

* JAVA-20464 Fix failing tests in hibernate-jpa module

---------

Co-authored-by: timis1 <noreplay@yahoo.com>
This commit is contained in:
timis1 2023-04-22 19:41:21 +03:00 committed by GitHub
parent 7d62cc1563
commit 9a47717d43
3 changed files with 6 additions and 9 deletions

View File

@ -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);

View File

@ -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());
}

View File

@ -30,7 +30,7 @@
<module>hibernate-mapping-2</module>
<!-- <module>hibernate-ogm</module>
<module>hibernate-annotations</module> FAILED -->
<!-- <module>hibernate-exceptions</module> FAILED -->
<module>hibernate-exceptions</module>
<module>hibernate-libraries</module>
<module>hibernate-jpa</module>
<!-- <module>hibernate-queries</module> FAILED -->