Skip to content

Commit

Permalink
HHH-14389 : Added test case. OneToOneWithDerivedIdentityTest#testFind…
Browse files Browse the repository at this point in the history
…ById reproduces the bug and is annotated with @FailureExpected

(cherry picked from commit 30fcb05)
  • Loading branch information
gbadner committed Feb 12, 2021
1 parent 0d1d2af commit 19df090
Showing 1 changed file with 79 additions and 0 deletions.
Expand Up @@ -51,6 +51,85 @@ public void testInsertFooAndBarWithDerivedId() {
s.close();
}

@Test
@TestForIssue(jiraKey = "HHH-14389")
public void testQueryById() {
Session s = openSession();
s.beginTransaction();
Bar bar = new Bar();
bar.setDetails( "Some details" );
Foo foo = new Foo();
foo.setBar( bar );
bar.setFoo( foo );
s.persist( foo );
s.flush();
assertNotNull( foo.getId() );
assertEquals( foo.getId(), bar.getFoo().getId() );

s.clear();
Bar newBar = ( Bar ) s.createQuery( "SELECT b FROM Bar b WHERE b.foo = :foo" )
.setParameter( "foo", foo )
.uniqueResult();
assertNotNull( newBar );
assertNotNull( newBar.getFoo() );
assertEquals( foo.getId(), newBar.getFoo().getId() );
assertEquals( "Some details", newBar.getDetails() );
s.getTransaction().rollback();
s.close();
}

@Test
@TestForIssue(jiraKey = "HHH-14389")
@FailureExpected( jiraKey = "HHH-14389")
public void testFindById() {
Session s = openSession();
s.beginTransaction();
Bar bar = new Bar();
bar.setDetails( "Some details" );
Foo foo = new Foo();
foo.setBar( bar );
bar.setFoo( foo );
s.persist( foo );
s.flush();
assertNotNull( foo.getId() );
assertEquals( foo.getId(), bar.getFoo().getId() );

s.clear();
Bar newBar = s.find( Bar.class, foo );
assertNotNull( newBar );
assertNotNull( newBar.getFoo() );
assertSame( foo, newBar.getFoo() );
assertEquals( foo.getId(), newBar.getFoo().getId() );
assertEquals( "Some details", newBar.getDetails() );
s.getTransaction().rollback();
s.close();
}

@Test
@TestForIssue(jiraKey = "HHH-14389")
public void testFindByPrimaryKey() {
Session s = openSession();
s.beginTransaction();
Bar bar = new Bar();
bar.setDetails( "Some details" );
Foo foo = new Foo();
foo.setBar( bar );
bar.setFoo( foo );
s.persist( foo );
s.flush();
assertNotNull( foo.getId() );
assertEquals( foo.getId(), bar.getFoo().getId() );

s.clear();
Bar newBar = s.find( Bar.class, foo.getId() );
assertNotNull( newBar );
assertNotNull( newBar.getFoo() );
assertEquals( foo.getId(), newBar.getFoo().getId() );
assertEquals( "Some details", newBar.getDetails() );
s.getTransaction().rollback();
s.close();
}

@Test
@TestForIssue( jiraKey = "HHH-10476")
public void testInsertFooAndBarWithDerivedIdPC() {
Expand Down

0 comments on commit 19df090

Please sign in to comment.