HHH-11196 - Hibernate 5 Bytecode Enhancement Association Management works just in one direction
- add replicating test case
This commit is contained in:
parent
d5ac64890c
commit
d59ac459fa
|
@ -8,8 +8,6 @@ package org.hibernate.test.bytecode.enhancement;
|
||||||
|
|
||||||
import org.hibernate.bytecode.enhance.spi.UnloadedClass;
|
import org.hibernate.bytecode.enhance.spi.UnloadedClass;
|
||||||
|
|
||||||
import org.hibernate.test.bytecode.enhancement.detached.DetachedGetIdentifierTestTask;
|
|
||||||
import org.hibernate.test.bytecode.enhancement.cascade.CascadeWithFkConstraintTestTask;
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.FailureExpected;
|
import org.hibernate.testing.FailureExpected;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
|
@ -21,10 +19,13 @@ import org.hibernate.test.bytecode.enhancement.access.MixedAccessTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.association.InheritedAttributeAssociationTestTask;
|
import org.hibernate.test.bytecode.enhancement.association.InheritedAttributeAssociationTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.association.ManyToManyAssociationTestTask;
|
import org.hibernate.test.bytecode.enhancement.association.ManyToManyAssociationTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.association.OneToManyAssociationTestTask;
|
import org.hibernate.test.bytecode.enhancement.association.OneToManyAssociationTestTask;
|
||||||
|
import org.hibernate.test.bytecode.enhancement.association.OneToManyBidirectionalAssociationTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.association.OneToOneAssociationTestTask;
|
import org.hibernate.test.bytecode.enhancement.association.OneToOneAssociationTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.basic.BasicEnhancementTestTask;
|
import org.hibernate.test.bytecode.enhancement.basic.BasicEnhancementTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.basic.HHH9529TestTask;
|
import org.hibernate.test.bytecode.enhancement.basic.HHH9529TestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.cascade.CascadeDeleteTestTask;
|
import org.hibernate.test.bytecode.enhancement.cascade.CascadeDeleteTestTask;
|
||||||
|
import org.hibernate.test.bytecode.enhancement.cascade.CascadeWithFkConstraintTestTask;
|
||||||
|
import org.hibernate.test.bytecode.enhancement.detached.DetachedGetIdentifierTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.dirty.DirtyTrackingCollectionTestTask;
|
import org.hibernate.test.bytecode.enhancement.dirty.DirtyTrackingCollectionTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.dirty.DirtyTrackingTestTask;
|
import org.hibernate.test.bytecode.enhancement.dirty.DirtyTrackingTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.eviction.EvictionTestTask;
|
import org.hibernate.test.bytecode.enhancement.eviction.EvictionTestTask;
|
||||||
|
@ -111,6 +112,12 @@ public class EnhancerTest extends BaseUnitTestCase {
|
||||||
EnhancerTestUtils.runEnhancerTestTask( InheritedAttributeAssociationTestTask.class );
|
EnhancerTestUtils.runEnhancerTestTask( InheritedAttributeAssociationTestTask.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@FailureExpected( jiraKey = "HHH-11196" )
|
||||||
|
public void testHHH11196() {
|
||||||
|
EnhancerTestUtils.runEnhancerTestTask( OneToManyBidirectionalAssociationTestTask.class );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLazy() {
|
public void testLazy() {
|
||||||
EnhancerTestUtils.runEnhancerTestTask( LazyLoadingTestTask.class );
|
EnhancerTestUtils.runEnhancerTestTask( LazyLoadingTestTask.class );
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* 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.bytecode.enhancement.association;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.test.bytecode.enhancement.AbstractEnhancerTestTask;
|
||||||
|
import org.junit.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luis Barreiro
|
||||||
|
*/
|
||||||
|
public class OneToManyBidirectionalAssociationTestTask extends AbstractEnhancerTestTask {
|
||||||
|
|
||||||
|
public Class<?>[] getAnnotatedClasses() {
|
||||||
|
return new Class<?>[] {Customer.class, CustomerInventory.class, Group.class, User.class};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void prepare() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
Customer customer = new Customer();
|
||||||
|
Assert.assertTrue( customer.getInventories().isEmpty() );
|
||||||
|
|
||||||
|
CustomerInventory customerInventory = new CustomerInventory();
|
||||||
|
customerInventory.setCustomer( customer );
|
||||||
|
|
||||||
|
Assert.assertTrue( customer.getInventories().size() == 1 );
|
||||||
|
Assert.assertTrue( customer.getInventories().contains( customerInventory ) );
|
||||||
|
|
||||||
|
Customer anotherCustomer = new Customer();
|
||||||
|
Assert.assertTrue( anotherCustomer.getInventories().isEmpty() );
|
||||||
|
customerInventory.setCustomer( anotherCustomer );
|
||||||
|
|
||||||
|
Assert.assertTrue( customer.getInventories().isEmpty() );
|
||||||
|
Assert.assertTrue( anotherCustomer.getInventories().size() == 1 );
|
||||||
|
Assert.assertTrue( anotherCustomer.getInventories().get( 0 ) == customerInventory );
|
||||||
|
|
||||||
|
customer.getInventories().add( customerInventory );
|
||||||
|
|
||||||
|
Assert.assertTrue( customerInventory.getCustomer() == customer );
|
||||||
|
Assert.assertTrue( anotherCustomer.getInventories().isEmpty() );
|
||||||
|
Assert.assertTrue( customer.getInventories().size() == 1 );
|
||||||
|
|
||||||
|
customer.addInventory( new CustomerInventory() );
|
||||||
|
Assert.assertTrue( customer.getInventories().size() == 2 );
|
||||||
|
|
||||||
|
// Test remove
|
||||||
|
|
||||||
|
List<CustomerInventory> inventories = customer.getInventories();
|
||||||
|
inventories.remove( customerInventory );
|
||||||
|
customer.setInventories( inventories );
|
||||||
|
|
||||||
|
// This happens (and is expected) because there was no snapshot taken beforeQuery remove
|
||||||
|
Assert.assertNotNull( customerInventory.getCustomer() );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void cleanup() {
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue