From cc31223b78db02811348384009ef75eaa559b3a6 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 12 Oct 2021 18:44:49 +0200 Subject: [PATCH] Re-enabled additional tests --- .../lazy/group/SimpleLazyGroupUpdateTest.java | 2 +- .../enhancement/lazy/proxy/Activity.java | 75 +++++++++++++++++++ .../enhancement/lazy/proxy/Address.java | 49 ++++++++++++ .../enhancement/lazy/proxy/BaseEntity.java | 45 +++++++++++ .../enhancement/lazy/proxy/Instruction.java | 41 ++++++++++ .../lazy/proxy/MergeProxyTest.java | 5 +- .../lazy/proxy/WebApplication.java | 69 +++++++++++++++++ 7 files changed, 281 insertions(+), 5 deletions(-) rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/bytecode/enhancement/lazy/group/SimpleLazyGroupUpdateTest.java (98%) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Activity.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Address.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/BaseEntity.java create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Instruction.java rename hibernate-core/src/test/java/org/hibernate/{ => orm}/test/bytecode/enhancement/lazy/proxy/MergeProxyTest.java (96%) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/WebApplication.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/group/SimpleLazyGroupUpdateTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/group/SimpleLazyGroupUpdateTest.java similarity index 98% rename from hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/group/SimpleLazyGroupUpdateTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/group/SimpleLazyGroupUpdateTest.java index 6c3ebde9e8..973041aad8 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/group/SimpleLazyGroupUpdateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/group/SimpleLazyGroupUpdateTest.java @@ -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.bytecode.enhancement.lazy.group; +package org.hibernate.orm.test.bytecode.enhancement.lazy.group; import org.hibernate.annotations.LazyGroup; import org.hibernate.bytecode.enhance.spi.UnloadedClass; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Activity.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Activity.java new file mode 100644 index 0000000000..cc9b656c86 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Activity.java @@ -0,0 +1,75 @@ +/* + * 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.bytecode.enhancement.lazy.proxy; + +import org.hibernate.annotations.LazyGroup; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +/** + * @author Steve Ebersole + */ +@Entity(name = "Activity") +@Table(name = "activity") +@SuppressWarnings("WeakerAccess") +public class Activity extends BaseEntity { + private String description; + private Instruction instruction; + + protected WebApplication webApplication = null; + + /** + * Used by Hibernate + */ + @SuppressWarnings("unused") + public Activity() { + super(); + } + + public Activity(Integer id, String description, Instruction instruction) { + super( id ); + this.description = description; + this.instruction = instruction; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE) + @LazyGroup("Instruction") + @JoinColumn(name = "Instruction_Id") + public Instruction getInstruction() { + return instruction; + } + + @SuppressWarnings("unused") + public void setInstruction(Instruction instruction) { + this.instruction = instruction; + } + + @SuppressWarnings("unused") + @ManyToOne(fetch=FetchType.LAZY) + @LazyGroup("webApplication") + @JoinColumn(name="web_app_oid") + public WebApplication getWebApplication() { + return webApplication; + } + + public void setWebApplication(WebApplication webApplication) { + this.webApplication = webApplication; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Address.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Address.java new file mode 100644 index 0000000000..06f7e90f16 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Address.java @@ -0,0 +1,49 @@ +/* + * 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.bytecode.enhancement.lazy.proxy; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; + +/** + * @author Steve Ebersole + */ +@Entity(name = "Address") +@Table(name = "address") +public class Address { + private Integer id; + + private String text; + + public Address() { + } + + public Address(Integer id, String text) { + this.id = id; + this.text = text; + } + + @Id + @Column(name = "oid") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/BaseEntity.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/BaseEntity.java new file mode 100644 index 0000000000..0f866e34a2 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/BaseEntity.java @@ -0,0 +1,45 @@ +/* + * 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.bytecode.enhancement.lazy.proxy; + +import jakarta.persistence.Column; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; + +/** + * @author Steve Ebersole + */ +@MappedSuperclass +public class BaseEntity { + protected Integer id; + protected String nbr; + + public BaseEntity() { + } + + public BaseEntity(Integer id) { + this.id = id; + } + + @Id + @Column( name = "oid" ) + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getNbr() { + return nbr; + } + + public void setNbr(String nbr) { + this.nbr = nbr; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Instruction.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Instruction.java new file mode 100644 index 0000000000..7d8e26cad5 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/Instruction.java @@ -0,0 +1,41 @@ +/* + * 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.bytecode.enhancement.lazy.proxy; + +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +/** + * @author Steve Ebersole + */ +@Entity(name = "Instruction") +@Table(name = "instruction") +public class Instruction extends BaseEntity { + private String summary; + + /** + * Used by Hibernate + */ + @SuppressWarnings("unused") + public Instruction() { + super(); + } + + @SuppressWarnings("WeakerAccess") + public Instruction(Integer id, String summary) { + super( id ); + this.summary = summary; + } + + public String getSummary() { + return summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/proxy/MergeProxyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/MergeProxyTest.java similarity index 96% rename from hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/proxy/MergeProxyTest.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/MergeProxyTest.java index 8dbef2857b..1cdb86a41a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/proxy/MergeProxyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/MergeProxyTest.java @@ -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.bytecode.enhancement.lazy.proxy; +package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy; import org.hibernate.Hibernate; import org.hibernate.boot.MetadataSources; @@ -20,9 +20,6 @@ import org.hibernate.testing.TestForIssue; import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner; import org.hibernate.testing.bytecode.enhancement.EnhancementOptions; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; -import org.hibernate.test.bytecode.enhancement.lazy.proxy.Activity; -import org.hibernate.test.bytecode.enhancement.lazy.proxy.Instruction; -import org.hibernate.test.bytecode.enhancement.lazy.proxy.WebApplication; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/WebApplication.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/WebApplication.java new file mode 100644 index 0000000000..1dac7f01b2 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/proxy/WebApplication.java @@ -0,0 +1,69 @@ +/* + * 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.bytecode.enhancement.lazy.proxy; + +import java.util.HashSet; +import java.util.Set; + +import org.hibernate.annotations.LazyGroup; +import org.hibernate.annotations.NaturalId; + +import jakarta.persistence.Basic; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; + +/** + * @author Steve Ebersole + */ +@Entity +@Table( name="web_app" ) +public class WebApplication extends BaseEntity { + private String name; + private String siteUrl; + + private Set activities = new HashSet<>(); + + @SuppressWarnings("unused") + public WebApplication() { + } + + public WebApplication(Integer id, String siteUrl) { + super( id ); + this.siteUrl = siteUrl; + } + + @NaturalId + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Basic( fetch = FetchType.LAZY ) + public String getSiteUrl() { + return siteUrl; + } + + public void setSiteUrl(String siteUrl) { + this.siteUrl = siteUrl; + } + + @OneToMany(mappedBy="webApplication", fetch= FetchType.LAZY) + @LazyGroup("app_activity_group") +// @CollectionType(type="baseutil.technology.hibernate.IskvLinkedSetCollectionType") + public Set getActivities() { + return activities; + } + + public void setActivities(Set activities) { + this.activities = activities; + } +}