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

Initial work on Jakata Persistence Driver for Jakarta Data #130

Merged
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
4 changes: 4 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ The Criteria API can be used via CriteriaDocumentTemplate.
</dependency>
----

== Driver for Jakarta Persistence entities

Provides a driver for Eclipse JNoSQL that supports Jakarta Persistence entities over a Jakarta Persistence provider. This project also contains a runner for the Jakarta Data TCK.

== TCK Runners

The Eclipse JNoSQL project provides Technology Compatibility Kit (TCK) runners for Jakarta Data. These runners allow you to run the TCK tests against the Eclipse JNoSQL implementation to verify its compatibility with the Jakarta Data specifications.
Expand Down
52 changes: 52 additions & 0 deletions jnosql-jakarta-persistence/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
= Eclipse JNoSQL driver for Jakarta Persistence
:toc: auto

This project provides a driver for Eclipse JNoSQL that supports Jakarta Persistence entities over a Jakarta Persistence provider.

Sub projects:

* link:jnosql-jakarta-persistence-driver[Jakarta Persistence Driver] - the actual implementation
* link:jnosql-jakarta-persistence-data-tck-runner[Jakarta Data TCK Runner] - the project to run the Jakarta Data TCK

=== How To Install

You can use either the Maven or Gradle dependencies:

[source,xml]
----
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-jakarta-persistence</artifactId>
</dependency>
----

Then you need to provide an EntityManager instance using a CDI producer, e.g.:

[source,java]
----
@ApplicationScoped
public class EntityManagerProducer {
@Produces
@ApplicationScoped
public EntityManager createEntityManager() {
return Persistence.createEntityManagerFactory("testPersistenceUnit")
.createEntityManager();
}

public void closeEntityManager(@Disposes EntityManager entityManager) {
entityManager.close();
}
}
----

Then you need to configure the persistence unit ("testPersistenceUnit") via standard Jakarta Persistence means, e.g.:

[source,xml]
----
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
<persistence-unit name="testPersistenceUnit" transaction-type="RESOURCE_LOCAL">
... custom configuration ...
</persistence-unit>
</persistence>

For an example configuration, with EclipseLink and DerbyDB, look into the test setup of the link:jnosql-jakarta-persistence-connector[Jakarta Persistence Connector] project.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
= Jakarta Data TCK Eclipse JNoSQL Implementation via Jakarta Persistence
:toc: auto

This project runs the Jakarta Data Technology Compatibility Kit (TCK) on standalone mode with Eclipse JNoSQL with the Jakarta Persistence connector. It uses EclipseLink and Derby DB as an implementation for Jakarta Persistence. Before running this project it is recommended to read the documentation located in the base link:https://github.com/jakartaee/data/blob/main/tck-dist/src/main/asciidoc/data-tck-reference-guide.adoc[TCK distribution project, _target=_blank].

== Overview

This project is configured specifically to allow the feature developers to run the TCK against the Eclipse JNoSQL implementation with the Jakarta Persistence backend.

== Running the TCK for Verification

Run the following command to execute the TCK:

[source,shell]
----
mvn clean test -B
----
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#Handlers we plan to use
handlers=java.util.logging.FileHandler,java.util.logging.ConsoleHandler

#Global logger - By default only log warnings
.level=WARNING

#Jakarta Data TCK logger - By default log everything for ee.jakarta.tck.data
ee.jakarta.tck.data.level=ALL

# Arquillian and JNoSQL - By default log everything, might reduce after development is complete.
org.jboss.level=ALL
org.eclipse.jnosql.level=ALL

#Formatting for the simple formatter
java.util.logging.SimpleFormatter.class.log=true
java.util.logging.SimpleFormatter.class.full=false
java.util.logging.SimpleFormatter.class.length=10

java.util.logging.SimpleFormatter.level.log=true

java.util.logging.SimpleFormatter.method.log=true
java.util.logging.SimpleFormatter.method.length=30

java.util.logging.SimpleFormatter.thread.log=true
java.util.logging.SimpleFormatter.thread.length=3

java.util.logging.SimpleFormatter.time.log=true
java.util.logging.SimpleFormatter.time.format=[MM/dd/yyyy HH:mm:ss:SSS z]

java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] %4$.1s %3$s %5$s %n

# Log warnings to console
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.level=WARNING

# Log everything else to file
java.util.logging.FileHandler.pattern=target/DataTCK%g%u.log
java.util.logging.FileHandler.limit = 500000
java.util.logging.FileHandler.count = 5
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level=CONFIG
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2024 Contributors to the Eclipse Foundation
~ All rights reserved. This program and the accompanying materials
~ are made available under the terms of the Eclipse Public License v1.0
~ and Apache License v2.0 which accompanies this distribution.
~ The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
~ and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
~
~ You may elect to redistribute this code under either of these licenses.
~
~ Contributors:
~
~ Ondro Mihalyi
~
-->
<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">

<modelVersion>4.0.0</modelVersion>
<name>Eclipse JNoSQL Jakarta Persistence Runner For Jakarta Data TCK</name>

<parent>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-jakarta-persistence-parent</artifactId>
<version>1.1.2-SNAPSHOT</version>
</parent>
<artifactId>jnosql-jakarta-persistence-data-tck-runner</artifactId>

<repositories>
<!-- For artifacts not yet in Maven Central -->
<repository>
<id>sonatype-nexus-staging</id>
<name>Sonatype Nexus Staging</name>
<url>https://jakarta.oss.sonatype.org/content/repositories/staging/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<properties>
<targetDirectory>${project.basedir}/target</targetDirectory>

<!-- Dependency versions -->
<jakarta.data.version>1.0.0</jakarta.data.version>
<jakarta.data.tck.version>1.0.1</jakarta.data.tck.version>
<jakarta.servlet.version>6.1.0</jakarta.servlet.version>
<jakarta.enterprise.cdi.version>4.1.0</jakarta.enterprise.cdi.version>

<arquillian.version>1.8.0.Final</arquillian.version>
<junit.version>5.10.2</junit.version>
<shrinkwrap.version>1.2.6</shrinkwrap.version>
<sigtest.version>2.3</sigtest.version>
<weld.junit5.version>4.0.3.Final</weld.junit5.version>
<testcontainers.version>1.19.8</testcontainers.version>
<!-- Pointer to logging.properties file that has the java.util.logging
configuration -->
<logging.config>${project.basedir}/logging.properties</logging.config>
<org.jboss.logging.provider>jdk</org.jboss.logging.provider>

<!-- TCK settings -->
<included.groups><![CDATA[standalone & persistence]]></included.groups>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<!-- Runtime Dependencies -->
<dependencies>
<!-- tck - data - external TCK -->
<dependency>
<groupId>jakarta.data</groupId>
<artifactId>jakarta.data-tck</artifactId>
<version>${jakarta.data.tck.version}</version>
</dependency>
<!-- api - data -->
<dependency>
<groupId>jakarta.data</groupId>
<artifactId>jakarta.data-api</artifactId>
<version>${jakarta.data.version}</version>
</dependency>
<!-- impl - data -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>5.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.17.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<version>10.17.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.17.1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.jnosql.mapping</groupId>
<artifactId>jnosql-jakarta-persistence</artifactId>
<version>${project.version}</version>
</dependency>
<!-- test frameworks -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>jakarta.tck</groupId>
<artifactId>sigtest-maven-plugin</artifactId>
<version>${sigtest.version}</version>
</dependency>
<!-- CDI for resource injection - managed by Junit -->
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-junit5</artifactId>
<version>${weld.junit5.version}</version>
</dependency>
<!-- APIs referenced by TCK that do not require implementations for standalone tests -->
<dependency>
<groupId>org.jboss.shrinkwrap</groupId>
<artifactId>shrinkwrap-api</artifactId>
<version>${shrinkwrap.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-core</artifactId>
<version>${arquillian.version}</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${jakarta.servlet.version}</version>
</dependency>
<!-- APIs referenced by TCK that do require implementations for standalone tests -->
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<directory>${targetDirectory}</directory>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
<failIfNoTests>true</failIfNoTests>
<statelessTestsetReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
<usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
<usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
</statelessTestsetReporter>
<systemPropertyVariables>
<java.util.logging.config.file>${logging.config}</java.util.logging.config.file>
<jimage.dir>target/tck-classes</jimage.dir>
<signature.sigTestClasspath>
${project.build.directory}/dependency/jakarta.data-api-${jakarta.data.api.version}.jar
</signature.sigTestClasspath>
<jakarta.tck.skip.deployment>true</jakarta.tck.skip.deployment>
</systemPropertyVariables>
<groups>${included.groups}</groups>
<reportNameSuffix>standalone</reportNameSuffix>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
*
* You may elect to redistribute this code under either of these licenses.
*
* Contributors:
*
* Ondro Mihalyi
*/
package org.eclipse.jnosql.tck.jakartapersistence;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Disposes;
import jakarta.enterprise.inject.Produces;
import jakarta.persistence.EntityManager;
import jakarta.persistence.Persistence;

@ApplicationScoped
public class EntityManagerProducer {
@Produces
@ApplicationScoped
public EntityManager createEntityManager() {
return Persistence.createEntityManagerFactory("testPersistenceUnit")
.createEntityManager();
}

public void closeEntityManager(@Disposes EntityManager entityManager) {
entityManager.close();
}
}
Loading