Skip to content

Commit

Permalink
HHH-13658 : Remove @LazyToOne(NO_PROXY) from classes used with byteco…
Browse files Browse the repository at this point in the history
…de-proxies enabled. FetchGraphTest#testRandomAccess failed so it was marked @FailureExpected.

(cherry picked from commit 602926b)
  • Loading branch information
gbadner committed Jan 14, 2021
1 parent ee1b4ab commit 15e59b3
Show file tree
Hide file tree
Showing 22 changed files with 2 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,24 @@ public abstract class AbstractKey extends ModelEntity
String name;

@OneToMany(targetEntity = RoleEntity.class, mappedBy = "key", fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("R")
protected Set<RoleEntity> roles = new LinkedHashSet<>();

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("PR")
@JoinColumn
protected AbstractKey register;

@OneToMany(targetEntity = AbstractKey.class, mappedBy = "register", fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("RK")
protected Set<AbstractKey> keys = new LinkedHashSet();

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("PP")
@JoinColumn
protected AbstractKey parent;

@OneToMany(targetEntity = AbstractKey.class, mappedBy = "parent", fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("PK")
protected Set<AbstractKey> otherKeys = new LinkedHashSet();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public void setDescription(String description) {
}

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("Instruction")
@JoinColumn(name = "Instruction_Id")
public Instruction getInstruction() {
Expand All @@ -66,7 +65,6 @@ public void setInstruction(Instruction instruction) {

@SuppressWarnings("unused")
@ManyToOne(fetch=FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("webApplication")
@JoinColumn(name="web_app_oid")
public WebApplication getWebApplication() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ public static class Employee {
private String name;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Employer employer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ public AEntity getA() {
}

@ManyToOne(fetch= FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("aEntity")
@JoinColumn(name="aEntity")
protected AEntity aChildEntity = null;
Expand Down Expand Up @@ -249,7 +248,6 @@ public AChildEntity getA() {
}

@ManyToOne(fetch= FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("aEntity")
@JoinColumn(name="aEntity")
protected AChildEntity aChildEntity = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ public static class CodeTableItem extends BaseEntity {
private CodeTable codeTable;

@OneToOne( mappedBy = "defaultItem", fetch=FetchType.LAZY )
@LazyToOne( LazyToOneOption.NO_PROXY )
@LazyGroup( "defaultItemInverse" )
protected CodeTable defaultItemInverse;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.stat.spi.StatisticsImplementor;

import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
import org.hibernate.testing.bytecode.enhancement.EnhancementOptions;
Expand Down Expand Up @@ -199,6 +200,7 @@ assert sessionFactory().getMetamodel()
}

@Test
@FailureExpected( jiraKey = "HHH-13658")
public void testRandomAccess() {
final StatisticsImplementor stats = sessionFactory().getStatistics();
stats.clear();
Expand Down Expand Up @@ -787,22 +789,17 @@ public static class DEntity extends BaseEntity {

// ****** Relations *****************
@OneToOne(fetch = FetchType.LAZY)
// @LazyToOne(LazyToOneOption.PROXY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("a")
public AEntity a;

@OneToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
// @LazyToOne(LazyToOneOption.PROXY)
@LazyGroup("c")
public CEntity c;

@OneToMany(targetEntity = BEntity.class)
public Set<BEntity> bs;

@OneToOne(mappedBy = "d", fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("e")
private EEntity e;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,15 @@ public static class OtherEntity {
private String id;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Animal animal = null;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Primate primate = null;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Human human = null;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Human otherHuman = null;

protected OtherEntity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,15 @@ public static class OtherEntity {
private String id;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Animal animal = null;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Primate primate = null;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Human human = null;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Human otherHuman = null;

protected OtherEntity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,15 +831,12 @@ public static class OtherEntity {
private String id;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Animal animal = null;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Primate primate = null;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Human human = null;

protected OtherEntity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,12 @@ public static class OtherEntity {
private String id;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Animal animal = null;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Primate primate = null;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Human human = null;

protected OtherEntity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,12 @@ public static class OtherEntity {
private String id;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Animal animal = null;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Primate primate = null;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Human human = null;

protected OtherEntity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ public static class Employee {
private String name;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Employer employer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ public static class Employee {

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(foreignKey = @ForeignKey(value= ConstraintMode.NO_CONSTRAINT))
@LazyToOne(LazyToOneOption.NO_PROXY)
@NotFound(action=NotFoundAction.IGNORE)
private Employer employer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public static class Employee {

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(foreignKey = @ForeignKey(value= ConstraintMode.NO_CONSTRAINT))
@LazyToOne(LazyToOneOption.NO_PROXY)
@NotFound(action=NotFoundAction.IGNORE)
private Employer employer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ public static class EmployerInfo {

@MapsId
@OneToOne(optional = false, fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Employer employer;

private String info;
Expand All @@ -165,7 +164,6 @@ public static class Employer {
private int id;

@OneToOne(optional = false, fetch = FetchType.LAZY, mappedBy = "employer", cascade = CascadeType.ALL)
@LazyToOne(LazyToOneOption.NO_PROXY)
private EmployerInfo employerInfo;

private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public static class EmployerInfo {

@MapsId
@OneToOne(optional = false, fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Employer employer;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ public static class AEntity {
private int id;

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private BEntity bEntity;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ public static class OtherEntity {
private String id;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@JoinColumn(name = "Employee_Id")
protected Employee employee = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,10 @@ public static class OtherEntity {
private String id;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@JoinColumn(name = "Employee_Id")
protected Employee employee = null;

@ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@JoinColumn(name = "EmployeeParent_Id")
protected EmployeeParent employeeParent = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ private static class Child {
Long id;

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
Parent parent;

@OneToMany
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ private static class Child {
Long id;

@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
Parent parent;

@OneToMany
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public void setSiteUrl(String siteUrl) {
}

@OneToMany(mappedBy="webApplication", fetch= FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("app_activity_group")
// @CollectionType(type="baseutil.technology.hibernate.IskvLinkedSetCollectionType")
public Set<Activity> getActivities() {
Expand Down

0 comments on commit 15e59b3

Please sign in to comment.