@Test public void testDetach() { doInHibernate( this::sessionFactory, s -> { Parent parent = s.find( Parent.class, parentID ); assertThat( parent, notNullValue() ); assertThat( parent, not( instanceOf( HibernateProxy.class ) ) ); assertFalse( isPropertyInitialized( parent, "children" ) ); checkDirtyTracking( parent ); s.detach( parent ); s.flush(); } ); }
@Test public void testOneToOneJoinIgnore() { setupTest( PersonOneToOneJoinIgnore.class, 1L, false ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonOneToOneJoinIgnore.class, 1L ); checkIgnore( pCheck ); } ); }
@Test public void testPkjcOneToOneJoinException() { setupTest( PersonPkjcJoinException.class, 1L, false ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonPkjcJoinException.class, 1L ); // @OneToOne @PrimaryKeyJoinColumn always assumes @NotFound(IGNORE) checkIgnore( pCheck ); } ); }
@Test public void testPkjcOneToOneSelectIgnore() { setupTest( PersonPkjcSelectIgnore.class, 1L, false ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonPkjcSelectIgnore.class, 1L ); // Person is non-null and association is null. checkIgnore( pCheck ); } ); }
@Test public void testOneToOneSelectIgnore() { setupTest( PersonOneToOneSelectIgnore.class, 1L, false ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonOneToOneSelectIgnore.class, 1L ); checkIgnore( pCheck ); } ); }
@Test public void testManyToOneJoinIgnore() { setupTest( PersonManyToOneJoinIgnore.class, 1L, false ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonManyToOneJoinIgnore.class, 1L ); checkIgnore( pCheck ); } ); }
@Test public void testMapsIdOneToOneJoinIgnore() { setupTest( PersonMapsIdJoinIgnore.class, 1L, true ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonMapsIdJoinIgnore.class, 1L ); // Person is non-null association is null. checkIgnore( pCheck ); } ); }
@Test public void testMapsIdOneToOneSelectIgnore() { setupTest( PersonMapsIdSelectIgnore.class, 1L, true ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonMapsIdSelectIgnore.class, 1L ); // Person is non-null association is null. checkIgnore( pCheck ); } ); }
@Test public void testMapsIdJoinColumnOneToOneSelectIgnore() { setupTest( PersonMapsIdColumnSelectIgnore.class, 1L, true ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonMapsIdColumnSelectIgnore.class, 1L ); checkIgnore( pCheck ); } ); }
@Test public void testMapsIdJoinColumnOneToOneJoinIgnore() { setupTest( PersonMapsIdColumnJoinIgnore.class, 1L, true ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonMapsIdColumnJoinIgnore.class, 1L ); checkIgnore( pCheck ); } ); }
@Test public void testManyToOneSelectIgnore() { setupTest( PersonManyToOneSelectIgnore.class, 1L, false ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonManyToOneSelectIgnore.class, 1L ); checkIgnore( pCheck ); } ); }
@Test public void testPkjcOneToOneJoinIgnore() { setupTest( PersonPkjcJoinIgnore.class, 1L, false ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonPkjcJoinIgnore.class, 1L ); // Person is non-null and association is null. checkIgnore( pCheck ); } ); }
@Test public void testPkjcOneToOneSelectException() { setupTest( PersonPkjcSelectException.class, 1L, false ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonPkjcSelectException.class, 1L ); // @OneToOne @PrimaryKeyJoinColumn always assumes @NotFound(IGNORE) checkIgnore( pCheck ); } ); }
@Test public void testConfiguredDiscriminatorValue() { final ChildEntity childEntity = new ChildEntity( 1, "Child" ); TransactionUtil.doInHibernate( this::sessionFactory, session -> { session.save( childEntity ); } ); TransactionUtil.doInHibernate( this::sessionFactory, session -> { ChildEntity ce = session.find( ChildEntity.class, 1 ); assertEquals( "ce", ce.getType() ); } ); }
@Test public void testOneToOneSelectIgnore() { setupTest( PersonOneToOneSelectIgnore.class, 1L, false ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonOneToOneSelectIgnore.class, 1L ); assertNotNull( pCheck ); assertNull( pCheck.getCity() ); } ); }
@Test public void testPkjcOneToOneSelectIgnore() { setupTest( PersonPkjcSelectIgnore.class, 1L, false ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonPkjcSelectIgnore.class, 1L ); // Person is non-null and association is null. assertNotNull( pCheck ); assertNull( pCheck.getCity() ); } ); }
@Test public void testMapsIdJoinColumnOneToOneSelectIgnore() { setupTest( PersonMapsIdColumnSelectIgnore.class, 1L, true ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonMapsIdColumnSelectIgnore.class, 1L ); // Person should be non-null;association should be null. assertNotNull( pCheck ); assertNull( pCheck.getCity() ); } ); }
@Test public void testManyToOneSelectIgnore() { setupTest( PersonManyToOneSelectIgnore.class, 1L, false ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonManyToOneSelectIgnore.class, 1L ); assertNotNull( pCheck ); assertNull( pCheck.getCity() ); } ); }
@Test public void testMapsIdOneToOneSelectIgnore() { setupTest( PersonMapsIdSelectIgnore.class, 1L, true ); doInHibernate( this::sessionFactory, session -> { Person pCheck = session.find( PersonMapsIdSelectIgnore.class, 1L ); // Person is non-null association is null. assertNotNull( pCheck ); assertNull( pCheck.getCity() ); } ); }
@Test @TestForIssue(jiraKey = "HHH-12541") public void testCalcViewEntity() throws Exception { Session s = openSession(); CVEntity cvEntity = s.find( CVEntity.class, "X" ); assertEquals( "X", cvEntity.getDummy() ); assertEquals( "XX", cvEntity.getDummydummy() ); assertEquals( 2, cvEntity.getDummyint() ); assertEquals( 1.5, cvEntity.getDummydouble(), 0.1 ); }