HHH-7138 - Hibernate implements JPA @OneToMany collection versioning incorrectly
This commit is contained in:
parent
7c60f01f2d
commit
497f700c16
|
@ -43,7 +43,56 @@ public class JpaSpecVersionValueUpdatingTest extends BaseCoreFunctionalTestCase
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testVersionNotIncrementedOnModificationOfNonOwningCollection() {
|
||||
public void testVersionNotIncrementedOnModificationOfNonOwningCollectionNonCascaded() {
|
||||
Session session = openSession();
|
||||
session.beginTransaction();
|
||||
Customer customer = new Customer();
|
||||
customer.id = 1L;
|
||||
session.save( customer );
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
long initial = customer.version;
|
||||
|
||||
session = openSession();
|
||||
session.beginTransaction();
|
||||
customer = (Customer) session.get( Customer.class, 1L );
|
||||
assertEquals( initial, customer.version );
|
||||
Order order = new Order();
|
||||
order.id = 1L;
|
||||
order.customer = customer;
|
||||
customer.orders.add( order );
|
||||
session.save( order );
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
assertEquals( initial, customer.version );
|
||||
|
||||
session = openSession();
|
||||
session.beginTransaction();
|
||||
customer = (Customer) session.get( Customer.class, 1L );
|
||||
assertEquals( initial, customer.version );
|
||||
Order order2 = new Order();
|
||||
order2.id = 2L;
|
||||
order2.customer = customer;
|
||||
customer.orders.add( order2 );
|
||||
session.save( order2 );
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
assertEquals( initial, customer.version );
|
||||
|
||||
session = openSession();
|
||||
session.beginTransaction();
|
||||
customer = (Customer) session.load( Customer.class, 1L );
|
||||
assertEquals( initial, customer.version );
|
||||
session.delete( customer );
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVersionNotIncrementedOnModificationOfNonOwningCollectionCascaded() {
|
||||
Customer customer = new Customer();
|
||||
customer.id = 1L;
|
||||
|
||||
|
|
Loading…
Reference in New Issue