-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Virtual Threads: performance impact with Helidon integration fix (pin…
…ning threads) (#2181) Plus new Maven test module to test EclipseLink with Helidon Skip Helidon tests for <JDK21 - JavaDoc generation Signed-off-by: Radek Felcman <[email protected]>
Showing
25 changed files
with
1,527 additions
and
370 deletions.
There are no files selected for viewing
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
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
437 changes: 281 additions & 156 deletions
437
...lipse.persistence.core/src/main/java/org/eclipse/persistence/indirection/IndirectMap.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
279 changes: 155 additions & 124 deletions
279
...ersistence.core/src/main/java/org/eclipse/persistence/sessions/server/ConnectionPool.java
Large diffs are not rendered by default.
Oops, something went wrong.
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,244 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License v. 2.0 which is available at | ||
http://www.eclipse.org/legal/epl-2.0, | ||
or the Eclipse Distribution License v. 1.0 which is available at | ||
http://www.eclipse.org/org/documents/edl-v10.php. | ||
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
Contributors: | ||
Oracle - initial API and implementation | ||
--> | ||
|
||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<name>EclipseLink JPA Helidon Test</name> | ||
<groupId>org.eclipse.persistence</groupId> | ||
<artifactId>org.eclipse.persistence.jpa.helidon.test</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<parent> | ||
<groupId>org.eclipse.persistence</groupId> | ||
<artifactId>org.eclipse.persistence.parent</artifactId> | ||
<version>4.0.4-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<properties> | ||
<mainClass>org.eclipse.persistence.testing.helidon.Main</mainClass> | ||
<!--Properties used for test resources filtering/replacement--> | ||
<!--DB connection properties--> | ||
<dbPlatform>${db.platform}</dbPlatform> | ||
<dbUser>${db.user}</dbUser> | ||
<dbPassword>${db.pwd}</dbPassword> | ||
<driverClass>${db.driver}</driverClass> | ||
<dbURL>${db.url}</dbURL> | ||
<!--Log level--> | ||
<loglevel>${logging.level}</loglevel> | ||
|
||
<test-skip-jpa-helidon>${skipTests}</test-skip-jpa-helidon> <!-- Spring 4 is not supported with jakarta.persistence --> | ||
</properties> | ||
|
||
<dependencies> | ||
<!--Other modules--> | ||
<!--EclipseLink JPA--> | ||
<dependency> | ||
<groupId>org.eclipse.persistence</groupId> | ||
<artifactId>org.eclipse.persistence.jpa</artifactId> | ||
</dependency> | ||
<!--API dependencies--> | ||
<dependency> | ||
<groupId>jakarta.transaction</groupId> | ||
<artifactId>jakarta.transaction-api</artifactId> | ||
</dependency> | ||
<!--Other libraries dependencies--> | ||
<dependency> | ||
<groupId>io.helidon.microprofile.bundles</groupId> | ||
<artifactId>helidon-microprofile</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.helidon.jersey</groupId> | ||
<artifactId>helidon-jersey-client</artifactId> | ||
</dependency> | ||
<!--Test dependencies--> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<!--JDBC driver (test dependency)--> | ||
<dependency> | ||
<groupId>${db.driver.groupId}</groupId> | ||
<artifactId>${db.driver.artifactId}</artifactId> | ||
<version>${db.driver.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<!--Filtering enables generate/substitute test properties from Maven into *.xml files.--> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
<testResources> | ||
<testResource> | ||
<directory>${integration.test.resources.directory}</directory> | ||
<filtering>true</filtering> | ||
</testResource> | ||
</testResources> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>default-compile</id> | ||
<configuration> | ||
<skipMain>true</skipMain> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<executions> | ||
<!-- need javadoc even in normal/short build | ||
for inclusion in binary distribution --> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.carlspring.maven</groupId> | ||
<artifactId>derby-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>start-derby</id> | ||
<phase>pre-integration-test</phase> | ||
<goals> | ||
<goal>start</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>stop-derby</id> | ||
<phase>post-integration-test</phase> | ||
<goals> | ||
<goal>stop</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>helidon-tests</id> | ||
<activation> | ||
<jdk>(21,</jdk> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<skip>false</skip> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>default-compile</id> | ||
<configuration> | ||
<skipMain>false</skipMain> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<workingDirectory>${project.build.directory}/test-run</workingDirectory> | ||
<!--Set system properties required for tests--> | ||
<systemPropertiesFile>${test.properties.file}</systemPropertiesFile> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>test-jpa-helidon</id> | ||
<goals> | ||
<goal>integration-test</goal> | ||
</goals> | ||
<configuration> | ||
<skipTests>${test-skip-jpa-helidon}</skipTests> | ||
<!--Analyze Virtual threads pinning issue | ||
<argLine>-Djdk.tracePinnedThreads=full</argLine> | ||
--> | ||
<reportNameSuffix>test-jpa-helidon</reportNameSuffix> | ||
<includes> | ||
<include>org.eclipse.persistence.testing.helidon.TestMaster</include> | ||
</includes> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>verify-integration-tests</id> | ||
<goals> | ||
<goal>verify</goal> | ||
</goals> | ||
<configuration> | ||
<skip>${integration.test.skip.verify}</skip> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
<profile> | ||
<id>oracle</id> | ||
<dependencies> | ||
<!--db.platform=org.eclipse.persistence.platform.database.oracle.Oracle23Platform comes from there--> | ||
<dependency> | ||
<groupId>org.eclipse.persistence</groupId> | ||
<artifactId>org.eclipse.persistence.oracle</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
<profile> | ||
<id>test-jpa-helidon</id> | ||
<properties> | ||
<test-skip-jpa-helidon>false</test-skip-jpa-helidon> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
</project> |
79 changes: 79 additions & 0 deletions
79
...link.jpa.helidon.test/src/it/java/org/eclipse/persistence/testing/helidon/TestMaster.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,79 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial API and implementation | ||
package org.eclipse.persistence.testing.helidon; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.ws.rs.client.Client; | ||
import jakarta.ws.rs.client.ClientBuilder; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import org.eclipse.persistence.testing.helidon.models.MasterEntity; | ||
|
||
import io.helidon.microprofile.server.Server; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class TestMaster { | ||
|
||
private static Server server; | ||
|
||
@BeforeClass | ||
public static void startServer() throws Exception { | ||
server = Main.startServer(); | ||
} | ||
|
||
@AfterClass | ||
public static void stopServer() throws Exception { | ||
if (server != null) { | ||
server.stop(); | ||
} | ||
} | ||
|
||
@Test | ||
public void testMasterOneRest() throws Exception { | ||
Client client = ClientBuilder.newClient(); | ||
MasterEntity masterEntity = client | ||
.target("http://localhost:8080/master/one") | ||
.request("application/json") | ||
.get(MasterEntity.class); | ||
assertEquals(1L, masterEntity.getId()); | ||
assertEquals("Master 1", masterEntity.getName()); | ||
} | ||
|
||
@Test | ||
public void testMasterAllRest() throws Exception { | ||
Client client = ClientBuilder.newClient(); | ||
List<MasterEntity> masterEntities = client | ||
.target("http://localhost:8080/master/all") | ||
.request("application/json") | ||
.get(List.class); | ||
assertTrue(masterEntities.size() >= 2); | ||
} | ||
|
||
@Test | ||
public void testMasterCreateRemoveRest() throws Exception { | ||
Client client = ClientBuilder.newClient(); | ||
Response response = client | ||
.target("http://localhost:8080/master/create_remove") | ||
.request("application/json") | ||
.get(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...ipselink.jpa.helidon.test/src/main/java/org/eclipse/persistence/testing/helidon/Main.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 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial API and implementation | ||
package org.eclipse.persistence.testing.helidon; | ||
|
||
import io.helidon.microprofile.server.Server; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
startServer(); | ||
} | ||
|
||
static Server startServer() { | ||
return Server.builder().retainDiscoveredApplications(true). | ||
build(). | ||
start(); | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
...k.jpa.helidon.test/src/main/java/org/eclipse/persistence/testing/helidon/dao/BaseDao.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,115 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial API and implementation | ||
package org.eclipse.persistence.testing.helidon.dao; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.EntityManagerFactory; | ||
import jakarta.persistence.Persistence; | ||
|
||
import org.eclipse.persistence.testing.helidon.models.BaseEntity; | ||
|
||
@Dependent | ||
public class BaseDao<T extends BaseEntity> { | ||
|
||
private EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("HelidonPu"); | ||
|
||
public void create(T entity) { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
try { | ||
entityManager.getTransaction().begin(); | ||
entityManager.persist(entity); | ||
entityManager.getTransaction().commit(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
throw new RuntimeException(); | ||
} finally { | ||
if (entityManager.getTransaction().isActive()) { | ||
entityManager.getTransaction().rollback(); | ||
} | ||
entityManager.close(); | ||
} | ||
} | ||
|
||
public void remove(T entity) { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
try { | ||
entityManager.getTransaction().begin(); | ||
T entity2 = entityManager.merge(entity);; | ||
entityManager.remove(entity2); | ||
entityManager.getTransaction().commit(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
throw new RuntimeException(); | ||
} finally { | ||
if (entityManager.getTransaction().isActive()) { | ||
entityManager.getTransaction().rollback(); | ||
} | ||
entityManager.close(); | ||
} | ||
} | ||
|
||
public T update(T entity) { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
T result = null; | ||
try { | ||
entityManager.getTransaction().begin(); | ||
result = entityManager.merge(entity); | ||
entityManager.getTransaction().commit(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
throw new RuntimeException(); | ||
} finally { | ||
if (entityManager.getTransaction().isActive()) { | ||
entityManager.getTransaction().rollback(); | ||
} | ||
entityManager.close(); | ||
} | ||
return result; | ||
} | ||
|
||
public T find(Class<T> clazz, long id) { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
try { | ||
return entityManager.find(clazz, id); | ||
} finally { | ||
if (entityManager.getTransaction().isActive()) { | ||
entityManager.getTransaction().rollback(); | ||
} | ||
entityManager.close(); | ||
} | ||
} | ||
|
||
public List<T> findByNamedQuery(String query) { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
List<T> result = null; | ||
try { | ||
entityManager.getTransaction().begin(); | ||
result = entityManager.createNamedQuery(query).getResultList(); | ||
entityManager.getTransaction().commit(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
throw new RuntimeException(); | ||
} finally { | ||
if (entityManager.getTransaction().isActive()) { | ||
entityManager.getTransaction().rollback(); | ||
} | ||
entityManager.close(); | ||
} | ||
return result; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...jpa.helidon.test/src/main/java/org/eclipse/persistence/testing/helidon/dao/DetailDao.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,23 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial API and implementation | ||
package org.eclipse.persistence.testing.helidon.dao; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
|
||
import org.eclipse.persistence.testing.helidon.models.DetailEntity; | ||
|
||
@Dependent | ||
public class DetailDao extends BaseDao<DetailEntity> { | ||
} |
23 changes: 23 additions & 0 deletions
23
...jpa.helidon.test/src/main/java/org/eclipse/persistence/testing/helidon/dao/MasterDao.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,23 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial API and implementation | ||
package org.eclipse.persistence.testing.helidon.dao; | ||
|
||
import jakarta.enterprise.context.Dependent; | ||
|
||
import org.eclipse.persistence.testing.helidon.models.MasterEntity; | ||
|
||
@Dependent | ||
public class MasterDao extends BaseDao<MasterEntity> { | ||
} |
38 changes: 38 additions & 0 deletions
38
...helidon.test/src/main/java/org/eclipse/persistence/testing/helidon/models/BaseEntity.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,38 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
package org.eclipse.persistence.testing.helidon.models; | ||
|
||
import jakarta.persistence.Id; | ||
import jakarta.persistence.MappedSuperclass; | ||
|
||
@MappedSuperclass | ||
public class BaseEntity { | ||
|
||
@Id | ||
private long id; | ||
|
||
public BaseEntity() { | ||
} | ||
|
||
public BaseEntity(long id) { | ||
this.id = id; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
...lidon.test/src/main/java/org/eclipse/persistence/testing/helidon/models/DetailEntity.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,66 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
package org.eclipse.persistence.testing.helidon.models; | ||
|
||
import jakarta.json.bind.annotation.JsonbTransient; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
|
||
@Entity | ||
@Table(name = "HELIDON_TAB_DETAIL") | ||
public class DetailEntity extends BaseEntity { | ||
|
||
private String name; | ||
|
||
@ManyToOne() | ||
@JoinColumn(name = "MASTER_ID_FK") | ||
@JsonbTransient | ||
private MasterEntity master; | ||
|
||
public DetailEntity() { | ||
} | ||
|
||
public DetailEntity(long id) { | ||
super(id); | ||
} | ||
|
||
public DetailEntity(long id, String name) { | ||
super(id); | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public MasterEntity getMaster() { | ||
return master; | ||
} | ||
|
||
public void setMaster(MasterEntity master) { | ||
this.master = master; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DetailEntity{" + | ||
"id='" + getId() + '\'' + | ||
"name='" + name + '\'' + | ||
'}'; | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
...lidon.test/src/main/java/org/eclipse/persistence/testing/helidon/models/MasterEntity.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,88 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial API and implementation | ||
package org.eclipse.persistence.testing.helidon.models; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.NamedQueries; | ||
import jakarta.persistence.NamedQuery; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
@Entity | ||
@Table(name = "HELIDON_TAB_MASTER") | ||
@NamedQueries({ | ||
@NamedQuery(name = "MasterEntity.findAll", query = "SELECT e FROM MasterEntity e"), | ||
}) | ||
public class MasterEntity extends BaseEntity { | ||
|
||
private String name; | ||
|
||
@OneToMany(mappedBy = "master") | ||
private List<DetailEntity> details = new ArrayList<>(); | ||
|
||
public MasterEntity() { | ||
} | ||
|
||
public MasterEntity(long id) { | ||
super(id); | ||
} | ||
|
||
public MasterEntity(long id, String name) { | ||
super(id); | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public List<DetailEntity> getDetails() { | ||
return details; | ||
} | ||
|
||
public void setDetails(List<DetailEntity> details) { | ||
this.details = details; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
MasterEntity that = (MasterEntity) o; | ||
return getId() == that.getId() && Objects.equals(name, that.name) && Objects.equals(details, that.details); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getId(), name, details); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MasterEntity{" + | ||
"id='" + getId() + '\'' + | ||
"name='" + name + '\'' + | ||
", details=" + details + | ||
'}'; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...n.test/src/main/java/org/eclipse/persistence/testing/helidon/provider/MasterProvider.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,47 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial API and implementation | ||
package org.eclipse.persistence.testing.helidon.provider; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
|
||
import org.eclipse.persistence.testing.helidon.dao.MasterDao; | ||
import org.eclipse.persistence.testing.helidon.models.MasterEntity; | ||
|
||
@ApplicationScoped | ||
public class MasterProvider { | ||
|
||
@Inject | ||
private MasterDao masterDao; | ||
|
||
public MasterEntity getMasterOne() { | ||
MasterEntity masterEntity = masterDao.find(MasterEntity.class, 1L); | ||
return masterEntity; | ||
} | ||
|
||
public List<MasterEntity> getMasterAll() { | ||
List<MasterEntity> masterEntities = masterDao.findByNamedQuery("MasterEntity.findAll"); | ||
return masterEntities; | ||
} | ||
|
||
public void createRemove() { | ||
MasterEntity masterEntity = new MasterEntity(3L, "Master 3"); | ||
masterDao.create(masterEntity); | ||
masterDao.remove(masterEntity); | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
...n.test/src/main/java/org/eclipse/persistence/testing/helidon/resource/MasterResource.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,55 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
// Oracle - initial API and implementation | ||
package org.eclipse.persistence.testing.helidon.resource; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.persistence.testing.helidon.models.MasterEntity; | ||
import org.eclipse.persistence.testing.helidon.provider.MasterProvider; | ||
|
||
@Path("/master") | ||
public class MasterResource { | ||
|
||
@Inject | ||
MasterProvider masterProvider; | ||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Path("one") | ||
public MasterEntity masterOne() { | ||
return masterProvider.getMasterOne(); | ||
} | ||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Path("all") | ||
public List<MasterEntity> masterAll() { | ||
return masterProvider.getMasterAll(); | ||
} | ||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Path("create_remove") | ||
public void createRemove() { | ||
masterProvider.createRemove();; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
jpa/eclipselink.jpa.helidon.test/src/main/resources/META-INF/beans.xml
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License v. 2.0 which is available at | ||
http://www.eclipse.org/legal/epl-2.0, | ||
or the Eclipse Distribution License v. 1.0 which is available at | ||
http://www.eclipse.org/org/documents/edl-v10.php. | ||
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
Contributors: | ||
Oracle - initial API and implementation | ||
--> | ||
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemalocation="https://jakarta.ee/xml/ns/jakartaee | ||
https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd" | ||
version="3.0" | ||
bean-discovery-mode="annotated"> | ||
</beans> |
17 changes: 17 additions & 0 deletions
17
jpa/eclipselink.jpa.helidon.test/src/main/resources/META-INF/microprofile-config.properties
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,17 @@ | ||
# | ||
# Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Eclipse Public License v. 2.0 which is available at | ||
# http://www.eclipse.org/legal/epl-2.0, | ||
# or the Eclipse Distribution License v. 1.0 which is available at | ||
# http://www.eclipse.org/org/documents/edl-v10.php. | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
# | ||
# Contributors: | ||
# Oracle - initial API and implementation | ||
|
||
# Microprofile server properties | ||
server.port=8080 | ||
server.host=0.0.0.0 |
32 changes: 32 additions & 0 deletions
32
jpa/eclipselink.jpa.helidon.test/src/main/resources/META-INF/persistence.xml
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,32 @@ | ||
<!-- | ||
Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License v. 2.0 which is available at | ||
http://www.eclipse.org/legal/epl-2.0, | ||
or the Eclipse Distribution License v. 1.0 which is available at | ||
http://www.eclipse.org/org/documents/edl-v10.php. | ||
SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
Contributors: | ||
Oracle - initial API and implementation | ||
--> | ||
<persistence xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd" version="3.0"> | ||
|
||
<persistence-unit name="HelidonPu" transaction-type="RESOURCE_LOCAL"> | ||
<class>org.eclipse.persistence.testing.helidon.models.MasterEntity</class> | ||
<class>org.eclipse.persistence.testing.helidon.models.DetailEntity</class> | ||
<properties> | ||
<property name="jakarta.persistence.jdbc.driver" value="@driverClass@" /> | ||
<property name="jakarta.persistence.jdbc.url" value="@dbURL@" /> | ||
<property name="jakarta.persistence.jdbc.user" value="@dbUser@" /> | ||
<property name="jakarta.persistence.jdbc.password" value="@dbPassword@" /> | ||
<!--property name="eclipselink.logging.level" value="FINE"/--> | ||
<!-- <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />--> | ||
<property name="jakarta.persistence.sql-load-script-source" value="META-INF/sql/init.sql"/> | ||
</properties> | ||
</persistence-unit> | ||
|
||
</persistence> |
26 changes: 26 additions & 0 deletions
26
jpa/eclipselink.jpa.helidon.test/src/main/resources/META-INF/sql/init.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,26 @@ | ||
-- | ||
-- Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. | ||
-- | ||
-- This program and the accompanying materials are made available under the | ||
-- terms of the Eclipse Public License v. 2.0 which is available at | ||
-- http://www.eclipse.org/legal/epl-2.0, | ||
-- or the Eclipse Distribution License v. 1.0 which is available at | ||
-- http://www.eclipse.org/org/documents/edl-v10.php. | ||
-- | ||
-- SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
-- | ||
-- Contributors: | ||
-- Oracle - initial API and implementation | ||
|
||
DROP TABLE HELIDON_TAB_DETAIL | ||
DROP TABLE HELIDON_TAB_MASTER | ||
CREATE TABLE HELIDON_TAB_MASTER (ID INTEGER PRIMARY KEY, NAME VARCHAR(200)) | ||
CREATE TABLE HELIDON_TAB_DETAIL (ID INTEGER PRIMARY KEY, MASTER_ID_FK INTEGER, NAME VARCHAR(200)) | ||
ALTER TABLE HELIDON_TAB_DETAIL ADD CONSTRAINT TEST_TAB_FK_DETAIL FOREIGN KEY ( MASTER_ID_FK ) REFERENCES HELIDON_TAB_MASTER (ID) | ||
|
||
INSERT INTO HELIDON_TAB_MASTER (ID, NAME)VALUES (1, 'Master 1') | ||
INSERT INTO HELIDON_TAB_MASTER (ID, NAME)VALUES (2, 'Master 2') | ||
INSERT INTO HELIDON_TAB_DETAIL (ID, MASTER_ID_FK, NAME)VALUES (101, 1, 'Detail 101') | ||
INSERT INTO HELIDON_TAB_DETAIL (ID, MASTER_ID_FK, NAME)VALUES (102, 1, 'Detail 102') | ||
INSERT INTO HELIDON_TAB_DETAIL (ID, MASTER_ID_FK, NAME)VALUES (201, 2, 'Detail 201') | ||
INSERT INTO HELIDON_TAB_DETAIL (ID, MASTER_ID_FK, NAME)VALUES (202, 2, 'Detail 202') |
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
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