mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-02-04 03:14:07 +01:00
[persistence.jpa] Upgrade openjpa and derby (#16591)
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, #16612 Signed-off-by: Holger Friedrich <mail@holger-friedrich.de> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
2f5f69ed7d
commit
debfb7fd81
@ -15,10 +15,8 @@
|
|||||||
<name>openHAB Add-ons :: Bundles :: Persistence Service :: JPA</name>
|
<name>openHAB Add-ons :: Bundles :: Persistence Service :: JPA</name>
|
||||||
|
|
||||||
<properties>
|
<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>
|
<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>3.2.2</openjpa.version>
|
<openjpa.version>4.0.0</openjpa.version>
|
||||||
<!-- workaround for Java 21 build, necessary until #16591 is merged -->
|
|
||||||
<maven.compiler.release>17</maven.compiler.release>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -32,12 +30,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.derby</groupId>
|
<groupId>org.apache.derby</groupId>
|
||||||
<artifactId>derby</artifactId>
|
<artifactId>derby</artifactId>
|
||||||
<version>10.14.2.0</version>
|
<version>10.16.1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.el</groupId>
|
<groupId>jakarta.el</groupId>
|
||||||
<artifactId>el-api</artifactId>
|
<artifactId>jakarta.el-api</artifactId>
|
||||||
<version>2.2</version>
|
<version>6.0.0-RC1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -19,12 +19,6 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
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.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.core.config.core.ConfigurableService;
|
import org.openhab.core.config.core.ConfigurableService;
|
||||||
@ -49,6 +43,12 @@ import org.osgi.service.component.annotations.Reference;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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.
|
* JPA based implementation of QueryablePersistenceService.
|
||||||
*
|
*
|
||||||
@ -277,13 +277,13 @@ public class JpaPersistenceService implements QueryablePersistenceService {
|
|||||||
logger.trace("Creating EntityManagerFactory...");
|
logger.trace("Creating EntityManagerFactory...");
|
||||||
|
|
||||||
Map<String, String> properties = new HashMap<>();
|
Map<String, String> properties = new HashMap<>();
|
||||||
properties.put("javax.persistence.jdbc.url", config.dbConnectionUrl);
|
properties.put("jakarta.persistence.jdbc.url", config.dbConnectionUrl);
|
||||||
properties.put("javax.persistence.jdbc.driver", config.dbDriverClass);
|
properties.put("jakarta.persistence.jdbc.driver", config.dbDriverClass);
|
||||||
if (!config.dbUserName.isBlank()) {
|
if (!config.dbUserName.isBlank()) {
|
||||||
properties.put("javax.persistence.jdbc.user", config.dbUserName);
|
properties.put("jakarta.persistence.jdbc.user", config.dbUserName);
|
||||||
}
|
}
|
||||||
if (!config.dbPassword.isBlank()) {
|
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()) {
|
if (config.dbUserName.isBlank() && config.dbPassword.isBlank()) {
|
||||||
logger.info("It is recommended to use a password to protect the JPA persistence data store");
|
logger.info("It is recommended to use a password to protect the JPA persistence data store");
|
||||||
|
@ -17,20 +17,20 @@ import java.time.ZoneId;
|
|||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.Date;
|
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.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.core.persistence.HistoricItem;
|
import org.openhab.core.persistence.HistoricItem;
|
||||||
import org.openhab.core.types.State;
|
import org.openhab.core.types.State;
|
||||||
import org.openhab.core.types.UnDefType;
|
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.
|
* This is the DAO object used for storing and retrieving to and from database.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user