Re-enable additional tests
This commit is contained in:
parent
26c3a1f32b
commit
e7992a35d4
|
@ -4,7 +4,7 @@
|
|||
* 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.component.complete;
|
||||
package org.hibernate.orm.test.propertyref.component.complete;
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* 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.component.complete;
|
||||
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.cache.spi.CacheImplementor;
|
||||
|
||||
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.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
@DomainModel(
|
||||
xmlMappings = "org/hibernate/orm/test/propertyref/component/complete/Mapping.hbm.xml",
|
||||
concurrencyStrategy = "nonstrict-read-write"
|
||||
)
|
||||
@SessionFactory
|
||||
public class CompleteComponentPropertyRefTest {
|
||||
|
||||
@Test
|
||||
public void testComponentPropertyRef(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
Person p = new Person();
|
||||
p.setIdentity( new Identity() );
|
||||
Account a = new Account();
|
||||
a.setNumber( "123-12345-1236" );
|
||||
a.setOwner( p );
|
||||
p.getIdentity().setName( "Gavin" );
|
||||
p.getIdentity().setSsn( "123-12-1234" );
|
||||
session.persist( p );
|
||||
session.persist( a );
|
||||
}
|
||||
);
|
||||
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
Account a = (Account) session.createQuery( "from Account a left join fetch a.owner" )
|
||||
.uniqueResult();
|
||||
assertTrue( Hibernate.isInitialized( a.getOwner() ) );
|
||||
assertNotNull( a.getOwner() );
|
||||
assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
|
||||
session.clear();
|
||||
|
||||
a = session.get( Account.class, "123-12345-1236" );
|
||||
assertFalse( Hibernate.isInitialized( a.getOwner() ) );
|
||||
assertNotNull( a.getOwner() );
|
||||
assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
|
||||
assertTrue( Hibernate.isInitialized( a.getOwner() ) );
|
||||
|
||||
session.clear();
|
||||
|
||||
final CacheImplementor cache = scope.getSessionFactory().getCache();
|
||||
cache.evictEntityData( Account.class );
|
||||
cache.evictEntityData( Person.class );
|
||||
|
||||
a = session.get( Account.class, "123-12345-1236" );
|
||||
assertTrue( Hibernate.isInitialized( a.getOwner() ) );
|
||||
assertNotNull( a.getOwner() );
|
||||
assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
|
||||
assertTrue( Hibernate.isInitialized( a.getOwner() ) );
|
||||
|
||||
session.delete( a );
|
||||
session.delete( a.getOwner() );
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* 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.component.complete;
|
||||
package org.hibernate.orm.test.propertyref.component.complete;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Identity implements Serializable {
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.propertyref.component.complete">
|
||||
<hibernate-mapping package="org.hibernate.orm.test.propertyref.component.complete">
|
||||
|
||||
<class name="Person" table="COMP_COMP_PROPREF_PERSON">
|
||||
<id name="id">
|
|
@ -4,7 +4,7 @@
|
|||
* 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.component.complete;
|
||||
package org.hibernate.orm.test.propertyref.component.complete;
|
||||
|
||||
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
//$Id: Account.java 7274 2005-06-22 17:07:29Z oneovthafew $
|
||||
package org.hibernate.test.propertyref.inheritence.joined;
|
||||
package org.hibernate.orm.test.propertyref.inheritence.joined;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
//$Id: BankAccount.java 7274 2005-06-22 17:07:29Z oneovthafew $
|
||||
package org.hibernate.test.propertyref.inheritence.joined;
|
||||
package org.hibernate.orm.test.propertyref.inheritence.joined;
|
||||
|
||||
|
||||
public class BankAccount extends Account {
|
|
@ -4,32 +4,35 @@
|
|||
* 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.inheritence.joined;
|
||||
package org.hibernate.orm.test.propertyref.inheritence.joined;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
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.Test;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.JoinType;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
public class JoinedSubclassPropertyRefTest extends BaseCoreFunctionalTestCase {
|
||||
public String[] getMappings() {
|
||||
return new String[] { "propertyref/inheritence/joined/Person.hbm.xml" };
|
||||
}
|
||||
@DomainModel(
|
||||
xmlMappings = "org/hibernate/orm/test/propertyref/inheritence/joined/Person.hbm.xml"
|
||||
)
|
||||
@SessionFactory
|
||||
public class JoinedSubclassPropertyRefTest {
|
||||
|
||||
@Test
|
||||
public void testPropertyRefToJoinedSubclass() {
|
||||
public void testPropertyRefToJoinedSubclass(SessionFactoryScope scope) {
|
||||
Person person = new Person();
|
||||
inTransaction(
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
person.setName( "Gavin King" );
|
||||
BankAccount acc = new BankAccount();
|
||||
|
@ -41,7 +44,7 @@ public class JoinedSubclassPropertyRefTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
);
|
||||
|
||||
inTransaction(
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
Person p = session.get( Person.class, person.getId() );
|
||||
assertNotNull( p.getBankAccount() );
|
||||
|
@ -49,7 +52,7 @@ public class JoinedSubclassPropertyRefTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
);
|
||||
|
||||
inTransaction(
|
||||
scope.inTransaction(
|
||||
session -> {
|
||||
CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
|
||||
CriteriaQuery<Person> criteria = criteriaBuilder.createQuery( Person.class );
|
||||
|
@ -64,7 +67,7 @@ public class JoinedSubclassPropertyRefTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
);
|
||||
|
||||
inTransaction(
|
||||
scope.inTransaction(
|
||||
session -> session.delete( person )
|
||||
);
|
||||
}
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
-->
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.propertyref.inheritence.joined">
|
||||
<hibernate-mapping package="org.hibernate.orm.test.propertyref.inheritence.joined">
|
||||
|
||||
<class name="Person" table="J_SBCLS_PROPREF_PERS">
|
||||
<id name="id">
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
//$Id: Person.java 7274 2005-06-22 17:07:29Z oneovthafew $
|
||||
package org.hibernate.test.propertyref.inheritence.joined;
|
||||
package org.hibernate.orm.test.propertyref.inheritence.joined;
|
||||
|
||||
|
||||
|
|
@ -1,81 +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.component.complete;
|
||||
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Gavin King
|
||||
*/
|
||||
public class CompleteComponentPropertyRefTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
return new String[] { "propertyref/component/complete/Mapping.hbm.xml" };
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCacheConcurrencyStrategy() {
|
||||
return "nonstrict-read-write";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComponentPropertyRef() {
|
||||
Session s = openSession();
|
||||
s.beginTransaction();
|
||||
Person p = new Person();
|
||||
p.setIdentity( new Identity() );
|
||||
Account a = new Account();
|
||||
a.setNumber("123-12345-1236");
|
||||
a.setOwner(p);
|
||||
p.getIdentity().setName("Gavin");
|
||||
p.getIdentity().setSsn("123-12-1234");
|
||||
s.persist(p);
|
||||
s.persist(a);
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
s.beginTransaction();
|
||||
a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult();
|
||||
assertTrue( Hibernate.isInitialized( a.getOwner() ) );
|
||||
assertNotNull( a.getOwner() );
|
||||
assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
|
||||
s.clear();
|
||||
|
||||
a = (Account) s.get(Account.class, "123-12345-1236");
|
||||
assertFalse( Hibernate.isInitialized( a.getOwner() ) );
|
||||
assertNotNull( a.getOwner() );
|
||||
assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
|
||||
assertTrue( Hibernate.isInitialized( a.getOwner() ) );
|
||||
|
||||
s.clear();
|
||||
|
||||
sessionFactory().getCache().evictEntityRegion( Account.class );
|
||||
sessionFactory().getCache().evictEntityRegion( Person.class );
|
||||
|
||||
a = (Account) s.get(Account.class, "123-12345-1236");
|
||||
assertTrue( Hibernate.isInitialized( a.getOwner() ) );
|
||||
assertNotNull( a.getOwner() );
|
||||
assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
|
||||
assertTrue( Hibernate.isInitialized( a.getOwner() ) );
|
||||
|
||||
s.delete( a );
|
||||
s.delete( a.getOwner() );
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue