mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-03-01 23:39:15 +00:00
Re-enabled additional tests
This commit is contained in:
parent
76089ae151
commit
cb2a2bbd58
@ -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.annotations.engine.collection;
|
||||
package org.hibernate.orm.test.annotations.engine.collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.persistence.Entity;
|
@ -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.annotations.engine.collection;
|
||||
package org.hibernate.orm.test.annotations.engine.collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.persistence.Entity;
|
@ -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.annotations.engine.collection;
|
||||
package org.hibernate.orm.test.annotations.engine.collection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.annotations.engine.collection;
|
||||
|
||||
import org.hibernate.Transaction;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
Father.class,
|
||||
Mother.class,
|
||||
Son.class
|
||||
}
|
||||
)
|
||||
@SessionFactory
|
||||
public class UnidirCollectionWithMultipleOwnerTest {
|
||||
|
||||
@Test
|
||||
public void testUnidirCollectionWithMultipleOwner(SessionFactoryScope scope) {
|
||||
scope.inSession(
|
||||
session -> {
|
||||
Transaction tx = session.beginTransaction();
|
||||
try {
|
||||
Father father = new Father();
|
||||
Mother mother = new Mother();
|
||||
session.save( father );
|
||||
//s.save( mother );
|
||||
Son son = new Son();
|
||||
father.getOrderedSons().add( son );
|
||||
son.setFather( father );
|
||||
mother.getSons().add( son );
|
||||
son.setMother( mother );
|
||||
session.save( mother );
|
||||
session.save( father );
|
||||
tx.commit();
|
||||
|
||||
session.clear();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
son = session.get( Son.class, son.getId() );
|
||||
session.delete( son );
|
||||
session.flush();
|
||||
father = session.get( Father.class, father.getId() );
|
||||
mother = session.get( Mother.class, mother.getId() );
|
||||
session.delete( father );
|
||||
session.delete( mother );
|
||||
tx.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
if ( tx.isActive() ) {
|
||||
tx.rollback();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
}
|
@ -1,59 +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.annotations.engine.collection;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class UnidirCollectionWithMultipleOwnerTest extends BaseCoreFunctionalTestCase {
|
||||
@Test
|
||||
public void testUnidirCollectionWithMultipleOwner() throws Exception {
|
||||
Session s = openSession();
|
||||
Transaction tx;
|
||||
tx = s.beginTransaction();
|
||||
Father father = new Father();
|
||||
Mother mother = new Mother();
|
||||
s.save( father );
|
||||
//s.save( mother );
|
||||
Son son = new Son();
|
||||
father.getOrderedSons().add( son );
|
||||
son.setFather( father );
|
||||
mother.getSons().add( son );
|
||||
son.setMother( mother );
|
||||
s.save( mother );
|
||||
s.save( father );
|
||||
tx.commit();
|
||||
|
||||
s.clear();
|
||||
|
||||
tx = s.beginTransaction();
|
||||
son = (Son) s.get( Son.class, son.getId() );
|
||||
s.delete( son );
|
||||
s.flush();
|
||||
father = (Father) s.get( Father.class, father.getId() );
|
||||
mother = (Mother) s.get( Mother.class, mother.getId() );
|
||||
s.delete( father );
|
||||
s.delete( mother );
|
||||
tx.commit();
|
||||
s.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
Father.class,
|
||||
Mother.class,
|
||||
Son.class
|
||||
};
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user