forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for quarkusio#8932 Hibernate Lazy load issue
- Loading branch information
Showing
7 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/Content.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
// } | ||
} |
15 changes: 15 additions & 0 deletions
15
integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/EntityBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
11 changes: 11 additions & 0 deletions
11
integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/Folder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
18 changes: 18 additions & 0 deletions
18
...ation-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/FolderEndPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.quarkus.it.panache; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Path("/folder") | ||
public class FolderEndPoint { | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello() { | ||
Folder f = Folder.findById(1L); | ||
Content content = f.content; | ||
return "name: " + content.name; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/Video.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
2 changes: 2 additions & 0 deletions
2
integration-tests/hibernate-orm-panache/src/main/resources/import.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
21 changes: 21 additions & 0 deletions
21
...ernate-orm-panache/src/test/java/io/quarkus/it/panache/HibernateProxyFieldAccessTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.quarkus.it.panache; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.is; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class HibernateProxyFieldAccessTest { | ||
|
||
@Test | ||
public void testHelloEndldpoint() { | ||
given() | ||
.when().get("/folder") | ||
.then() | ||
.statusCode(200) | ||
.body(is("name: it is working!")); | ||
} | ||
} |