mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +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>
This commit is contained in:
parent
f79a2dd7f0
commit
dcd778301b
@ -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>
|
||||
@ -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>
|
||||
|
||||
|
@ -19,12 +19,6 @@ import java.util.Locale;
|
||||
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;
|
||||
@ -49,6 +43,12 @@ import org.osgi.service.component.annotations.Reference;
|
||||
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.
|
||||
*
|
||||
@ -277,13 +277,13 @@ public class JpaPersistenceService implements QueryablePersistenceService {
|
||||
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");
|
||||
|
@ -17,20 +17,20 @@ import java.time.ZoneId;
|
||||
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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user