Skip to content

Commit

Permalink
[persistence.jpa] Upgrade openjpa and derby (openhab#16591)
Browse files Browse the repository at this point in the history
Support Java 21

- Upgrade openjpa from 3.2.2 to 4.0.0
- Upgrade derby from 10.14.2.0 to 10.16.1.1 (last Java 17 release)
- Migrate javax.el to jakarta.el-api 6.0.0-RC1
- Revert workaround for Java 21, openhab#16612

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
Signed-off-by: Paul Smedley <paul@smedley.id.au>
  • Loading branch information
holgerfriedrich authored and psmedley committed Jun 15, 2024
1 parent 9cc8b71 commit 533da89
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
14 changes: 6 additions & 8 deletions bundles/org.openhab.persistence.jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
<name>openHAB Add-ons :: Bundles :: Persistence Service :: JPA</name>

<properties>
<bnd.importpackage>!com.ibm.*,!com.sun.*,!oracle.*,!javax.interceptor.*,!javax.enterprise.*,!javax.rmi,!org.apache.bval.*,!net.sf.cglib.*,!org.apache.commons.beanutils.*,!org.apache.geronimo.*,!org.apache.avalon.*,!org.apache.log,!org.apache.tools.*,!org.apache.xerces.*,!org.jboss.*,!org.postgresql.*,!org.slf4j.impl,!weblogic.*,org.apache.derby.*;resolution:=optional</bnd.importpackage>
<openjpa.version>3.2.2</openjpa.version>
<!-- workaround for Java 21 build, necessary until #16591 is merged -->
<maven.compiler.release>17</maven.compiler.release>
<bnd.importpackage>!com.ibm.*,!com.sun.*,!oracle.*,!jakarta.interceptor.*,!jakarta.enterprise.*,!javax.enterprise.*,!javax.transaction.*,!jakarta.xml.*,!javax.rmi,!org.apache.bval.*,!net.sf.cglib.*,!org.apache.commons.beanutils.*,!org.apache.geronimo.*,!org.apache.avalon.*,!org.apache.log,!org.apache.tools.*,!org.apache.xerces.*,!org.jboss.*,!org.postgresql.*,!org.slf4j.impl,!weblogic.*,org.apache.derby.*;resolution:=optional</bnd.importpackage>
<openjpa.version>4.0.0</openjpa.version>
</properties>

<dependencies>
Expand All @@ -32,12 +30,12 @@
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.14.2.0</version>
<version>10.16.1.1</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
<version>6.0.0-RC1</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
import java.util.Map;
import java.util.Set;

import javax.persistence.EntityExistsException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.config.core.ConfigurableService;
Expand All @@ -49,6 +43,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jakarta.persistence.EntityExistsException;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.Persistence;
import jakarta.persistence.Query;

/**
* JPA based implementation of QueryablePersistenceService.
*
Expand Down Expand Up @@ -277,13 +277,13 @@ protected EntityManagerFactory newEntityManagerFactory() {
logger.trace("Creating EntityManagerFactory...");

Map<String, String> properties = new HashMap<>();
properties.put("javax.persistence.jdbc.url", config.dbConnectionUrl);
properties.put("javax.persistence.jdbc.driver", config.dbDriverClass);
properties.put("jakarta.persistence.jdbc.url", config.dbConnectionUrl);
properties.put("jakarta.persistence.jdbc.driver", config.dbDriverClass);
if (!config.dbUserName.isBlank()) {
properties.put("javax.persistence.jdbc.user", config.dbUserName);
properties.put("jakarta.persistence.jdbc.user", config.dbUserName);
}
if (!config.dbPassword.isBlank()) {
properties.put("javax.persistence.jdbc.password", config.dbPassword);
properties.put("jakarta.persistence.jdbc.password", config.dbPassword);
}
if (config.dbUserName.isBlank() && config.dbPassword.isBlank()) {
logger.info("It is recommended to use a password to protect the JPA persistence data store");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
import java.time.ZonedDateTime;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.persistence.HistoricItem;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;

/**
* This is the DAO object used for storing and retrieving to and from database.
*
Expand Down

0 comments on commit 533da89

Please sign in to comment.