Skip to content

Commit

Permalink
Merge pull request #22 from emmanuelbernard/JPABoot
Browse files Browse the repository at this point in the history
Integrate JPA into Shamrock
  • Loading branch information
stuartwdouglas authored Sep 17, 2018
2 parents 491f682 + a26d104 commit c81e38b
Show file tree
Hide file tree
Showing 29 changed files with 1,355 additions and 0 deletions.
173 changes: 173 additions & 0 deletions examples/jpa-strict/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>shamrock-examples-parent</artifactId>
<groupId>org.jboss.shamrock</groupId>
<version>1.0.0.Alpha1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>shamrock-strict-jpa-example</artifactId>
<description>An example that only contains JPA related tests running in strict mode</description>
<dependencies>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-jaxrs-deployment</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-jpa-deployment</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql-protean</artifactId>
<version>42.2.5-SNAPSHOT</version>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shamrock</groupId>
<artifactId>shamrock-graal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>shamrock-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.26.1</version>
<configuration>
<images>
<image>
<name>postgres:10.5</name>
<alias>postgresql</alias>
<run>
<env>
<POSTGRES_USER>hibernate_orm_test</POSTGRES_USER>
<POSTGRES_PASSWORD>hibernate_orm_test</POSTGRES_PASSWORD>
<POSTGRES_DB>hibernate_orm_test</POSTGRES_DB>
</env>
<ports>
<port>5432:5432</port>
</ports>
<wait>
<tcp>
<mode>mapped</mode>
<ports>
<port>5432</port>
</ports>
</tcp>
<time>10000</time>
</wait>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>docker-start</id>
<phase>compile</phase>
<goals>
<goal>stop</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>docker-stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native-image</id>
<activation>
<property>
<name>!no-native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemProperties>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>shamrock-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>native-image</id>
<goals>
<goal>native-image</goal>
</goals>
<configuration>
<reportErrorsAtRuntime>false</reportErrorsAtRuntime>
<cleanupServer>true</cleanupServer>
<enableHttpUrlHandler>true</enableHttpUrlHandler>
<!-- Requires Protean Graal fork to work, will fail otherwise
<enableRetainedHeapReporting>true</enableRetainedHeapReporting>
<enableCodeSizeReporting>true</enableCodeSizeReporting>
-->
<graalvmHome>${graalvmHome}</graalvmHome>
<enableJni>false</enableJni>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.jboss.shamrock.example;

public class MainMethod {

public static void main(String... args) throws Exception {
Class.forName("org.jboss.shamrock.runtime.RuntimeRunner");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.jboss.shamrock.example.jpa;

import javax.persistence.Embeddable;

/**
* This is an enmarked @Embeddable class.
* Let's see if just being referenced by the main entity is enough to be detected.
*
* @author Emmanuel Bernard [email protected]
*/
//FIXME : this used to be non-annotated explicitly for testing purposes
// added the annotation as it's illegal according to the ORM metadata validation
@Embeddable
public class Address {
private String street1;
private String street2;
private String zipCode;

public String getStreet1() {
return street1;
}

public void setStreet1(String street1) {
this.street1 = street1;
}

public String getStreet2() {
return street2;
}

public void setStreet2(String street2) {
this.street2 = street2;
}

public String getZipCode() {
return zipCode;
}

public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.jboss.shamrock.example.jpa;

/**
* @author Emmanuel Bernard [email protected]
*/
public class Animal {
private double weight;

public double getWeight() {
return weight;
}

public void setWeight(double weight) {
this.weight = weight;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.jboss.shamrock.example.jpa;

import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Id;

/**
* Used to test reflection references for JPA
*
* @author Emmanuel Bernard [email protected]
*/
@Entity
public class Customer extends Human {
@Id
// no getter explicitly to test field only reflective access
private Long id;

private Address address;
private WorkAddress workAddress;

private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

// Address is referenced but not marked as @Embeddable
@Embedded
public Address getAddress() {
return address;
}

public WorkAddress getWorkAddress() {
return workAddress;
}

public void setWorkAddress(WorkAddress workAddress) {
this.workAddress = workAddress;
}

public void setAddress(Address address) {
this.address = address;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.jboss.shamrock.example.jpa;

import javax.persistence.MappedSuperclass;

/**
* Mapped superclass test
*
* @author Emmanuel Bernard [email protected]
*/
@MappedSuperclass
public class Human extends Animal {
private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
Loading

0 comments on commit c81e38b

Please sign in to comment.