Re-enabled additional tests
This commit is contained in:
parent
94c4bcf66f
commit
8d6ada3357
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/
|
||||||
|
package org.hibernate.orm.test.propertyref.cachedcollections;
|
||||||
|
|
||||||
|
import org.hibernate.Hibernate;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of tests originally developed to verify and fix HHH-5853
|
||||||
|
*
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@TestForIssue(jiraKey = "HHH-5853")
|
||||||
|
@DomainModel(
|
||||||
|
xmlMappings = "org/hibernate/orm/test/propertyref/cachedcollections/Mappings.hbm.xml"
|
||||||
|
)
|
||||||
|
@SessionFactory
|
||||||
|
public class CachedPropertyRefCollectionTest {
|
||||||
|
|
||||||
|
private ManagedObject mo;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void setUp(SessionFactoryScope scope) {
|
||||||
|
scope.inTransaction(
|
||||||
|
session -> {
|
||||||
|
mo = new ManagedObject( "test", "test" );
|
||||||
|
mo.getMembers().add( "members" );
|
||||||
|
session.save( mo );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void tearDown(SessionFactoryScope scope) {
|
||||||
|
scope.inTransaction(
|
||||||
|
session ->
|
||||||
|
session.delete( mo )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRetrievalOfCachedCollectionWithPropertyRefKey(SessionFactoryScope scope) {
|
||||||
|
// First attempt to load it via PK lookup
|
||||||
|
scope.inTransaction(
|
||||||
|
session -> {
|
||||||
|
ManagedObject obj = session.get( ManagedObject.class, 1L );
|
||||||
|
assertNotNull( obj );
|
||||||
|
assertTrue( Hibernate.isInitialized( obj ) );
|
||||||
|
obj.getMembers().size();
|
||||||
|
assertTrue( Hibernate.isInitialized( obj.getMembers() ) );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Now try to access it via natural key
|
||||||
|
scope.inTransaction(
|
||||||
|
session -> {
|
||||||
|
ManagedObject obj = session.bySimpleNaturalId( ManagedObject.class ).load( "test" );
|
||||||
|
assertNotNull( obj );
|
||||||
|
assertTrue( Hibernate.isInitialized( obj ) );
|
||||||
|
obj.getMembers().size();
|
||||||
|
assertTrue( Hibernate.isInitialized( obj.getMembers() ) );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.propertyref.cachedcollections;
|
package org.hibernate.orm.test.propertyref.cachedcollections;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
|
@ -8,7 +8,7 @@
|
||||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||||
|
|
||||||
<hibernate-mapping package="org.hibernate.test.propertyref.cachedcollections">
|
<hibernate-mapping package="org.hibernate.orm.test.propertyref.cachedcollections">
|
||||||
|
|
||||||
<class name="ManagedObject">
|
<class name="ManagedObject">
|
||||||
<cache usage="read-write"/>
|
<cache usage="read-write"/>
|
|
@ -1,72 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
||||||
*/
|
|
||||||
package org.hibernate.test.propertyref.cachedcollections;
|
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
|
||||||
import org.hibernate.Session;
|
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set of tests originally developed to verify and fix HHH-5853
|
|
||||||
*
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
@TestForIssue( jiraKey = "HHH-5853" )
|
|
||||||
public class CachedPropertyRefCollectionTest extends BaseCoreFunctionalTestCase {
|
|
||||||
@Override
|
|
||||||
public String[] getMappings() {
|
|
||||||
return new String[]{"propertyref/cachedcollections/Mappings.hbm.xml"};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRetrievalOfCachedCollectionWithPropertyRefKey() {
|
|
||||||
// create the test data...
|
|
||||||
Session session = openSession();
|
|
||||||
session.beginTransaction();
|
|
||||||
ManagedObject mo = new ManagedObject( "test", "test" );
|
|
||||||
mo.getMembers().add( "members" );
|
|
||||||
session.save( mo );
|
|
||||||
session.getTransaction().commit();
|
|
||||||
session.close();
|
|
||||||
|
|
||||||
// First attempt to load it via PK lookup
|
|
||||||
session = openSession();
|
|
||||||
session.beginTransaction();
|
|
||||||
ManagedObject obj = session.get( ManagedObject.class, 1L );
|
|
||||||
assertNotNull( obj );
|
|
||||||
assertTrue( Hibernate.isInitialized( obj ) );
|
|
||||||
obj.getMembers().size();
|
|
||||||
assertTrue( Hibernate.isInitialized( obj.getMembers() ) );
|
|
||||||
session.getTransaction().commit();
|
|
||||||
session.close();
|
|
||||||
|
|
||||||
// Now try to access it via natural key
|
|
||||||
session = openSession();
|
|
||||||
session.beginTransaction();
|
|
||||||
obj = session.bySimpleNaturalId( ManagedObject.class ).load( "test" );
|
|
||||||
assertNotNull( obj );
|
|
||||||
assertTrue( Hibernate.isInitialized( obj ) );
|
|
||||||
obj.getMembers().size();
|
|
||||||
assertTrue( Hibernate.isInitialized( obj.getMembers() ) );
|
|
||||||
session.getTransaction().commit();
|
|
||||||
session.close();
|
|
||||||
|
|
||||||
// Clean up
|
|
||||||
session = openSession();
|
|
||||||
session.beginTransaction();
|
|
||||||
session.delete( obj );
|
|
||||||
session.getTransaction().commit();
|
|
||||||
session.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue