-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
201f3bc
commit a811d16
Showing
10 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...ts/quarkus/extension-codestarts/hibernate-orm-codestart/base/README.tpl.qute.md
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 @@ | ||
{#include readme-header /} |
5 changes: 5 additions & 0 deletions
5
...rkus/extension-codestarts/hibernate-orm-codestart/base/src/main/resources/application.yml
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,5 @@ | ||
# drop and create the database at startup (use `update` to only update the schema) | ||
quarkus: | ||
hibernate-orm: | ||
database: | ||
generation: drop-and-create |
3 changes: 3 additions & 0 deletions
3
...s/quarkus/extension-codestarts/hibernate-orm-codestart/base/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,3 @@ | ||
insert into myentity (id, field) values(nextval('hibernate_sequence'), 'field-1'); | ||
insert into myentity (id, field) values(nextval('hibernate_sequence'), 'field-2'); | ||
insert into myentity (id, field) values(nextval('hibernate_sequence'), 'field-3'); |
12 changes: 12 additions & 0 deletions
12
...n/resources/codestarts/quarkus/extension-codestarts/hibernate-orm-codestart/codestart.yml
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,12 @@ | ||
name: hibernate-orm-codestart | ||
ref: hibernate-orm | ||
tags: extension-codestart | ||
type: code | ||
metadata: | ||
title: Hibernate ORM | ||
description: Create your first JPA entity | ||
related-guide-section: https://quarkus.io/guides/hibernate-orm | ||
language: | ||
base: | ||
dependencies: | ||
- io.quarkus:quarkus-hibernate-orm |
29 changes: 29 additions & 0 deletions
29
...us/extension-codestarts/hibernate-orm-codestart/java/src/main/java/org/acme/MyEntity.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,29 @@ | ||
package org.acme; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
|
||
@Entity | ||
public class MyEntity { | ||
private Long id; | ||
private String field; | ||
|
||
@Id | ||
@GeneratedValue | ||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getField() { | ||
return field; | ||
} | ||
|
||
public void setField(String field) { | ||
this.field = field; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...xtension-codestarts/hibernate-orm-codestart/java/src/test/java/org/acme/MyEntityTest.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,22 @@ | ||
package org.acme; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
import java.util.List; | ||
|
||
@QuarkusTest | ||
public class MyEntityTest { | ||
@Inject | ||
EntityManager em; | ||
|
||
@Test | ||
public void testMyEntity() { | ||
List<MyEntity> entities = em.createQuery("from MyEntity", MyEntity.class).getResultList(); | ||
Assertions.assertEquals(3, entities.size()); | ||
} | ||
|
||
} |
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
30 changes: 30 additions & 0 deletions
30
...tools/src/test/java/io/quarkus/devtools/codestarts/quarkus/HibernateOrmCodestartTest.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,30 @@ | ||
package io.quarkus.devtools.codestarts.quarkus; | ||
|
||
import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.JAVA; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest; | ||
|
||
public class HibernateOrmCodestartTest { | ||
|
||
@RegisterExtension | ||
public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder() | ||
.codestarts("hibernate-orm") | ||
.languages(JAVA) | ||
.build(); | ||
|
||
@Test | ||
void testContent() throws Throwable { | ||
codestartTest.checkGeneratedSource("org.acme.MyEntity"); | ||
codestartTest.checkGeneratedTestSource("org.acme.MyEntityTest"); | ||
} | ||
|
||
@Test | ||
@EnabledIfSystemProperty(named = "build-projects", matches = "true") | ||
void buildAllProjectsForLocalUse() throws Throwable { | ||
codestartTest.buildAllProjects(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...pshots__/HibernateOrmCodestartTest/testContent/src_main_java_ilove_quark_us_MyEntity.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,29 @@ | ||
package ilove.quark.us; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
|
||
@Entity | ||
public class MyEntity { | ||
private Long id; | ||
private String field; | ||
|
||
@Id | ||
@GeneratedValue | ||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getField() { | ||
return field; | ||
} | ||
|
||
public void setField(String field) { | ||
this.field = field; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ts__/HibernateOrmCodestartTest/testContent/src_test_java_ilove_quark_us_MyEntityTest.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,22 @@ | ||
package ilove.quark.us; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.inject.Inject; | ||
import javax.persistence.EntityManager; | ||
import java.util.List; | ||
|
||
@QuarkusTest | ||
public class MyEntityTest { | ||
@Inject | ||
EntityManager em; | ||
|
||
@Test | ||
public void testMyEntity() { | ||
List<MyEntity> entities = em.createQuery("from MyEntity", MyEntity.class).getResultList(); | ||
Assertions.assertEquals(3, entities.size()); | ||
} | ||
|
||
} |