Skip to content

Commit

Permalink
Test for quarkusio#8932 Hibernate Lazy load issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 committed May 15, 2020
1 parent c17e637 commit 681e0c5
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.quarkus.it.panache;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;

@Entity(name = "content")
@Inheritance(strategy = InheritanceType.JOINED)
public class Content extends EntityBase {
@Column(nullable = false)
public String name;

// public String getName() {
// return name;
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.quarkus.it.panache;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

import io.quarkus.hibernate.orm.panache.PanacheEntityBase;

@MappedSuperclass
public abstract class EntityBase extends PanacheEntityBase {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.quarkus.it.panache;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;

@Entity(name = "folder")
public class Folder extends EntityBase {
@ManyToOne(fetch = FetchType.LAZY, optional = false)
public Content content;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.quarkus.it.panache;

import javax.persistence.Column;
import javax.persistence.Entity;

@Entity(name = "video")
public class Video extends Content {
@Column(nullable = false)
public long length;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
insert into content values (1, 'it is working!');
insert into folder values (1, 1);
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.quarkus.it.panache;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
public class HibernateProxyFieldAccessTest {

@Test
public void folderContentNameTest() {
Folder f = Folder.findById(1L);
Content content = f.content;
String name = content.name;
Assertions.assertEquals("it is working!", name);
}
}

0 comments on commit 681e0c5

Please sign in to comment.