From 80360b131793df287d8322c0f89478ad8116ee63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 25 Jun 2018 14:15:35 +0200 Subject: [PATCH] HHH-12594 Trim down BatchFetchBootstrapTest to the simplest possible configuration So that we can investigate without unnecessary complexity getting in the way. --- .../batchfetch/BatchFetchBootstrapTest.java | 148 +----------------- 1 file changed, 4 insertions(+), 144 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/batchfetch/BatchFetchBootstrapTest.java b/hibernate-core/src/test/java/org/hibernate/test/batchfetch/BatchFetchBootstrapTest.java index fb203a76ec..80e7ecbe22 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/batchfetch/BatchFetchBootstrapTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/batchfetch/BatchFetchBootstrapTest.java @@ -1,33 +1,14 @@ package org.hibernate.test.batchfetch; -import java.sql.Blob; import java.util.LinkedHashSet; import java.util.Set; -import javax.persistence.Basic; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Lob; import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; import javax.persistence.MappedSuperclass; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; -import org.hibernate.annotations.Cache; -import org.hibernate.annotations.CacheConcurrencyStrategy; -import org.hibernate.annotations.Cascade; -import org.hibernate.annotations.CascadeType; -import org.hibernate.annotations.Fetch; -import org.hibernate.annotations.FetchMode; -import org.hibernate.annotations.LazyToOne; -import org.hibernate.annotations.LazyToOneOption; -import org.hibernate.annotations.Polymorphism; -import org.hibernate.annotations.PolymorphismType; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; @@ -40,7 +21,7 @@ public class BatchFetchBootstrapTest extends BaseCoreFunctionalTestCase { @Override protected Class[] getAnnotatedClasses() { return new Class[] { - Authority.class, JafSid.class, UserGroup.class, File.class + JafSid.class, UserGroup.class }; } @@ -59,33 +40,6 @@ public class BatchFetchBootstrapTest extends BaseCoreFunctionalTestCase { super.buildSessionFactory(); } - @Entity(name = "File") - @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy") - public static class File extends Base { - - private Blob blob; - private Base parent; - - @Column(name = "filedata", length = 1024 * 1024) - @Lob - @Basic(fetch = FetchType.LAZY) - public Blob getBlob() { - return blob; - } - - public void setBlob(Blob blob) { - this.blob = blob; - } - - @ManyToOne(fetch = FetchType.LAZY) - public Base getParent() { - return parent; - } - - public void setParent(Base parent) { - this.parent = parent; - } - } @MappedSuperclass public abstract static class DatabaseEntity { @@ -103,46 +57,12 @@ public class BatchFetchBootstrapTest extends BaseCoreFunctionalTestCase { } - @Entity(name = "Base") - @Polymorphism(type = PolymorphismType.EXPLICIT) - @Inheritance(strategy = InheritanceType.JOINED) - public abstract static class Base extends DatabaseEntity { - - private Set files; - - @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY) - @Fetch(FetchMode.SUBSELECT) - public Set getFiles() { - return files; - } - - public void setFiles(Set files) { - this.files = files; - } - } - - @Entity(name = "Authority") - public static class Authority extends SidEntity { - private String authority; - - public String getAuthority() { - return authority; - } - - public void setAuthority(String authority) { - this.authority = authority; - } - } - @Entity(name = "JafSid") - public static class JafSid extends Base { + public static class JafSid extends DatabaseEntity { private Set groups = new LinkedHashSet<>(); - private SidEntity relatedEntity; - private String sid; @ManyToMany(mappedBy = "members", fetch = FetchType.EAGER) - @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public Set getGroups() { return groups; } @@ -150,74 +70,14 @@ public class BatchFetchBootstrapTest extends BaseCoreFunctionalTestCase { public void setGroups(Set groups) { this.groups = groups; } - - @OneToOne(fetch = FetchType.LAZY) - @LazyToOne(LazyToOneOption.NO_PROXY) - public SidEntity getRelatedEntity() { - return relatedEntity; - } - - public void setRelatedEntity(SidEntity relatedEntity) { - this.relatedEntity = relatedEntity; - } - - public String getSid() { - return sid; - } - - public void setSid(String sid) { - this.sid = sid; - } - } - - @Entity(name = "SidEntity") - public static class SidEntity extends Base { - - private JafSid sid; - - @OneToOne(mappedBy = "relatedEntity", optional = false, fetch = FetchType.EAGER, orphanRemoval = true) - @Cascade(CascadeType.ALL) - public JafSid getSid() { - return sid; - } - - public void setSid(JafSid sid) { - this.sid = sid; - } - } - - @Entity(name = "User") - public static class User extends SidEntity { - - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } } @Entity(name = "UserGroup") - public static class UserGroup extends SidEntity { + public static class UserGroup extends DatabaseEntity { - private Set authorities = new LinkedHashSet<>(); private Set members = new LinkedHashSet<>(); - @ManyToMany(targetEntity = Authority.class, fetch = FetchType.LAZY) - @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) - public Set getAuthorities() { - return authorities; - } - - public void setAuthorities(Set authorities) { - this.authorities = authorities; - } - - @ManyToMany(fetch = FetchType.LAZY) - @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + @ManyToMany public Set getMembers() { return members; }