Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oracle DB with JPA #2044

Merged
merged 1 commit into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ final class FeatureCatalog {
"Tracing",
"Tracing support",
"Tracing");
addSe("io.helidon.webclient",
"WebClient",
"Helidon WebClient",
"WebClient");
addSe("io.helidon.webserver",
"WebServer",
"Helidon WebServer",
Expand Down Expand Up @@ -491,9 +487,10 @@ final class FeatureCatalog {
exclude("io.helidon.config.spi");
exclude("io.helidon.config.mp");
exclude("io.helidon.config.mp.spi");
exclude("io.helidon.dbclient.spi");
exclude("io.helidon.dbclient.jdbc.spi");
exclude("io.helidon.dbclient.common");
exclude("io.helidon.dbclient.jdbc.spi");
exclude("io.helidon.dbclient.metrics.jdbc");
exclude("io.helidon.dbclient.spi");
exclude("io.helidon.health.common");
exclude("io.helidon.integrations.cdi.delegates");
exclude("io.helidon.integrations.cdi.referencecountedcontext");
Expand Down
6 changes: 6 additions & 0 deletions integrations/db/ojdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc10</artifactId>
<exclusions>
<exclusion>
<groupId>com.oracle.ojdbc</groupId>
tomas-langer marked this conversation as resolved.
Show resolved Hide resolved
<artifactId>ucp</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ Args= --allow-incomplete-classpath \
--initialize-at-run-time=oracle.net.nt.Clock \
--initialize-at-run-time=oracle.net.nt.TcpMultiplexer \
--initialize-at-run-time=oracle.net.nt.TcpMultiplexer \
--initialize-at-run-time=oracle.net.nt.TcpMultiplexer$LazyHolder
--initialize-at-run-time=oracle.net.nt.TcpMultiplexer$LazyHolder \
--initialize-at-run-time=oracle.jdbc.driver.SQLUtil$XMLFactory \
--initialize-at-run-time=oracle.jdbc.driver.NamedTypeAccessor$XMLFactory
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[
{
"name": "org.hibernate.dialect.Oracle10gDialect",
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicMethods": true,
"allDeclaredFields": true,
"allPublicFields": true
},
{
"name": "oracle.jdbc.internal.ACProxyable",
"methods": [
Expand Down
19 changes: 16 additions & 3 deletions tests/integration/native-image/mp-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@ Requires at least GraalVM 20.0.0
This test validates that JPA integration (using Hibernate) and JTA
integration work in native image.

This test requires a running h2 database on `jdbc:h2:tcp://localhost:9092/test`
This test requires a running oracle database on `jdbc:oracle:thin:@localhost:1521/XE`
username `system`, password `oracle` (or modify `microprofile-config.properties` to match your DB)
with the following table and data:

`CREATE TABLE GREETING (FIRSTPART VARCHAR NOT NULL, SECONDPART VARCHAR NOT NULL, PRIMARY KEY (FIRSTPART))`
```sql
CREATE TABLE GREETING (FIRSTPART VARCHAR2(100), SECONDPART VARCHAR2(100), PRIMARY KEY (FIRSTPART))
INSERT INTO GREETING (FIRSTPART, SECONDPART) VALUES ('Jack', 'The Ripper')
```

`INSERT INTO GREETING (FIRSTPART, SECONDPART) VALUES ('Jack', 'The Ripper')`
Once the test is done against Oracle DB database, switch to h2:

Make sure the table exists and contains expected data:
```sql
CREATE TABLE GREETING (FIRSTPART VARCHAR NOT NULL, SECONDPART VARCHAR NOT NULL, PRIMARY KEY (FIRSTPART))
INSERT INTO GREETING (FIRSTPART, SECONDPART) VALUES ('Jack', 'The Ripper')
```


1. Comment out `ojdbc` and uncomment `h2` in `pom.xml`
2. Comment out `org.hibernate.dialect.Oracle10gDialect"` and uncomment `org.hibernate.dialect.H2Dialect` in `persistence.xml`
3. Comment out all oracle driver properties and uncomment all h2 driver properties in `microprofile-config.properties`
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.EntityNotFoundException;
import javax.persistence.PersistenceContext;
import javax.transaction.Transaction;
import javax.transaction.Transactional;
Expand Down Expand Up @@ -75,14 +74,15 @@ public Response post(@PathParam("firstPart") String firstPart, String secondPart
GreetingEntity greeting;

boolean created = false;
try {
greeting = this.entityManager.getReference(GreetingEntity.class, firstPart);
greeting.setSecondPart(secondPart);
//entityManager.persist(greeting);
} catch (EntityNotFoundException entityNotFoundException) {

greeting = this.entityManager.find(GreetingEntity.class, firstPart);

if (greeting == null) {
greeting = new GreetingEntity(firstPart, secondPart);
entityManager.persist(greeting);
created = true;
} else {
greeting.setSecondPart(secondPart);
}

if (created) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ private static void validateDb(Errors.Collector collector, WebTarget target) {

response = jack.request().get();
validateResponse(response, collector, path, "Sparrow");

response = jack.request().post(Entity.text("The Ripper"));
validateResponse(response, collector, path, "Jack");

response = jack.request().get();
validateResponse(response, collector, path, "The Ripper");
}

private static void validateResponse(Response response, Errors.Collector collector, String path, String expected) {
Expand Down