From 5ca06af029f975bd6364d4fd969137002546176a Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 26 Jul 2023 12:08:56 +0200 Subject: [PATCH] Revert "HHH-16959 Add test for issue" This reverts commit 6c767eab1f3396526d377adc91253ab2bce752e1. --- ...stedEmbeddableWithLockingDeletionTest.java | 224 ------------------ 1 file changed, 224 deletions(-) delete mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/embeddable/NestedEmbeddableWithLockingDeletionTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/embeddable/NestedEmbeddableWithLockingDeletionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/embeddable/NestedEmbeddableWithLockingDeletionTest.java deleted file mode 100644 index c088fcff35..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/embeddable/NestedEmbeddableWithLockingDeletionTest.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.hibernate.orm.test.embeddable; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.List; - -import org.hibernate.annotations.DynamicUpdate; -import org.hibernate.annotations.OptimisticLockType; -import org.hibernate.annotations.OptimisticLocking; -import org.hibernate.cfg.AvailableSettings; - -import org.hibernate.testing.orm.junit.DomainModel; -import org.hibernate.testing.orm.junit.JiraKey; -import org.hibernate.testing.orm.junit.ServiceRegistry; -import org.hibernate.testing.orm.junit.SessionFactory; -import org.hibernate.testing.orm.junit.SessionFactoryScope; -import org.hibernate.testing.orm.junit.Setting; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; - -import jakarta.persistence.Column; -import jakarta.persistence.Embeddable; -import jakarta.persistence.Embedded; -import jakarta.persistence.Entity; -import jakarta.persistence.Id; -import jakarta.persistence.IdClass; -import jakarta.persistence.Table; - -import static org.assertj.core.api.Assertions.assertThat; - -@DomainModel( - annotatedClasses = { - NestedEmbeddableWithLockingDeletionTest.Product.class, - - } -) -@SessionFactory -@ServiceRegistry( - settings = { - @Setting(name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "20") - } -) -@JiraKey("HHH-16959") -public class NestedEmbeddableWithLockingDeletionTest { - - @AfterEach - public void tearDown(SessionFactoryScope scope) { - scope.inTransaction( - session -> - session.createMutationQuery( "delete from Product" ).executeUpdate() - ); - } - - @Test - public void shouldDeleteAllProducts(SessionFactoryScope scope) { - scope.inTransaction( - session -> { - TypeOneBenefit typeOneBenefit = new TypeOneBenefit( BigDecimal.TEN ); - Product product = new Product( "ID1", new Benefits( typeOneBenefit, null ), "test" ); - session.persist( product ); - - Product product2 = new Product( "ID2", new Benefits( null, "data" ) ); - - session.persist( product2 ); - - Product product3 = new Product( "ID3", null, "test" ); - session.persist( product3 ); - } - ); - - deleteAllProducts( scope ); - - assertProductsHaveBeenDeleted( scope ); - } - - @Test - public void shouldDeleteOneProduct1(SessionFactoryScope scope) { - scope.inTransaction( - session -> { - Product product = new Product( "ID1", new Benefits( null, "data" ) ); - session.persist( product ); - } - ); - - deleteAllProducts( scope ); - - assertProductsHaveBeenDeleted( scope ); - - } - - @Test - public void shouldDeleteOneProduct2(SessionFactoryScope scope) { - scope.inTransaction( - session -> { - Product product = new Product( "ID1", null, "test" ); - session.persist( product ); - - } - ); - - deleteAllProducts( scope ); - - assertProductsHaveBeenDeleted( scope ); - } - - @Test - public void shouldDeleteOneProduct3(SessionFactoryScope scope) { - scope.inTransaction( - session -> { - TypeOneBenefit typeOneBenefit = new TypeOneBenefit( BigDecimal.TEN ); - Product product = new Product( "ID1", new Benefits( typeOneBenefit, null ), "test" ); - session.persist( product ); - } - ); - - deleteAllProducts( scope ); - - assertProductsHaveBeenDeleted( scope ); - - } - - private static void deleteAllProducts(SessionFactoryScope scope) { - scope.inTransaction( - session -> { - List products = session.createQuery( - "select p from Product p", - Product.class - ).list(); - - products.forEach( - p -> { - session.remove( p ); - } - ); - } - ); - } - - private static void assertProductsHaveBeenDeleted(SessionFactoryScope scope) { - scope.inTransaction( - session -> { - List products = session.createQuery( "select p from Product p", Product.class ).list(); - assertThat( products.size() ).isEqualTo( 0 ); - } - ); - } - - @IdClass(ProductPK.class) - @Entity(name = "Product") - @OptimisticLocking(type = OptimisticLockType.ALL) - @DynamicUpdate - @Table(name = "PRODUCTS") - public static class Product { - - @Id - private String productId; - - - private String description; - - @Embedded - private Benefits benefits; - - public Product() { - } - - public Product(String productId) { - this.productId = productId; - } - - public Product(String productId, Benefits benefits) { - this.productId = productId; - this.benefits = benefits; - } - - public Product(String productId, Benefits benefits, String description) { - this.productId = productId; - this.benefits = benefits; - this.description = description; - } - } - - public static class ProductPK implements Serializable { - private String productId; - - public ProductPK() { - } - - public ProductPK(String productId) { - this.productId = productId; - } - } - - @Embeddable - public static class Benefits { - - @Embedded - TypeOneBenefit credit; - - String data; - - public Benefits() { - } - - public Benefits(TypeOneBenefit credit, String data) { - this.credit = credit; - this.data = data; - } - } - - @Embeddable - public static class TypeOneBenefit { - @Column(name = "BENEFIT_ONE_BASE_AMOUNT") - BigDecimal baseAmount; - - public TypeOneBenefit() { - } - - public TypeOneBenefit(BigDecimal baseAmount) { - this.baseAmount = baseAmount; - } - } - -}