-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18218 from Sanne/MultilineImportsReactive
Hibernate Reactive to use multi-line import scripts
- Loading branch information
Showing
3 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...-reactive/deployment/src/test/java/io/quarkus/hibernate/reactive/MultiLineImportTest.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,63 @@ | ||
package io.quarkus.hibernate.reactive; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Table; | ||
|
||
import org.hibernate.reactive.mutiny.Mutiny; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
public class MultiLineImportTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClass(Hero.class) | ||
.addAsResource("complexMultilineImports.sql", "import.sql")) | ||
.withConfigurationResource("application.properties"); | ||
|
||
@Inject | ||
Mutiny.SessionFactory sessionFactory; | ||
|
||
@Test | ||
public void integerIdentifierWithStageAPI() { | ||
final Uni<List<Object>> result = sessionFactory.withSession(s -> s.createQuery( | ||
"from Hero h where h.name = :name").setParameter("name", "Galadriel").getResultList()); | ||
final List<Object> list = result.await().indefinitely(); | ||
assertThat(list).hasSize(1); | ||
} | ||
|
||
@Entity(name = "Hero") | ||
@Table(name = "hero") | ||
public static class Hero { | ||
|
||
@javax.persistence.Id | ||
@javax.persistence.GeneratedValue | ||
public java.lang.Long id; | ||
|
||
@Column(unique = true) | ||
public String name; | ||
|
||
public String otherName; | ||
|
||
public int level; | ||
|
||
public String picture; | ||
|
||
@Column(columnDefinition = "TEXT") | ||
public String powers; | ||
|
||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
extensions/hibernate-reactive/deployment/src/test/resources/complexMultilineImports.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,10 @@ | ||
-- tag::adocSQL[] | ||
INSERT INTO hero(id, name, otherName, picture, powers, level) | ||
VALUES (nextval('hibernate_sequence'), 'Chewbacca', '', 'https://www.superherodb.com/pictures2/portraits/10/050/10466.jpg', 'Agility, Longevity, Marksmanship, Natural Weapons, Stealth, Super Strength, Weapons Master', 5); | ||
INSERT INTO hero(id, name, otherName, picture, powers, level) | ||
VALUES (nextval('hibernate_sequence'), 'Angel Salvadore', 'Angel Salvadore Bohusk', 'https://www.superherodb.com/pictures2/portraits/10/050/1406.jpg', 'Animal Attributes, Animal Oriented Powers, Flight, Regeneration, Toxin and Disease Control', 4); | ||
INSERT INTO hero(id, name, otherName, picture, powers, level) | ||
VALUES (nextval('hibernate_sequence'), 'Bill Harken', '', 'https://www.superherodb.com/pictures2/portraits/10/050/1527.jpg', 'Super Speed, Super Strength, Toxin and Disease Resistance', 6); | ||
-- end::adocSQL[] | ||
INSERT INTO hero(id, name, otherName, picture, powers, level) | ||
VALUES (nextval('hibernate_sequence'), 'Galadriel', '', 'https://www.superherodb.com/pictures2/portraits/11/050/11796.jpg', 'Danger Sense, Immortality, Intelligence, Invisibility, Magic, Precognition, Telekinesis, Telepathy', 17); |
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