From 84a3a42fd03936033cf526c78409616a3729fdaa Mon Sep 17 00:00:00 2001 From: timis1 <12120641+timis1@users.noreply.github.com> Date: Fri, 7 Apr 2023 04:53:12 +0300 Subject: [PATCH] JAVA-18167 Upgrade persistence-modules to JDK 11 (#13714) * JAVA-18167 Upgrade persistence-modules to JDK 11 (activejdbc and core-java-persistence) * JAVA-16167 Update pom.xml to include just the updated modules * JAVA-18167 Added vaadin because it looks that I removed * JAVA-18167 Migration deltaspike * JAVA-18167 Migration hbase module * JAVA-18167 Migration hibernate-mapping-2 * JAVA-18167 Migration hibernate-exceptions * JAVA-18167 Migration hibernate-jpa module * JAVA-18167 Migration hibernate-jpa change the name of User entity * JAVA-18167 Overwriting the version of slf4j and logback for hibernate-jpa * JAVA-18167 Migrate deltaspike back to jdk8 * JAVA-18167 Remove some modules that was added elsewhere * Revert "JAVA-18167 Migration deltaspike" This reverts commit 874b4ba2 * JAVA-18167 Comment failed module (it will be migrated later) --------- Co-authored-by: timis1 --- .gitignore | 1 + persistence-modules/activejdbc/pom.xml | 4 +- .../main/java/com/baeldung/ActiveJDBCApp.java | 4 +- .../core-java-persistence/pom.xml | 17 ++-- .../baeldung/jdbcmetadata/DatabaseConfig.java | 13 +-- .../jdbcmetadata/JdbcMetadataApplication.java | 7 +- .../jdbcrowset/DatabaseConfiguration.java | 4 - .../jdbcrowset/JdbcRowsetApplication.java | 18 ++--- .../jdbcrowset/JdbcRowSetLiveTest.java | 22 +++-- .../baeldung/spring/jdbc/JdbcLiveTest.java | 5 +- .../spring/jdbc/ResultSetLiveTest.java | 3 - persistence-modules/hbase/pom.xml | 2 +- .../baeldung/hbase/HbaseClientExample.java | 8 +- .../hibernate-exceptions/pom.xml | 8 +- .../entitynotfoundexception/Category.java | 2 +- .../entitynotfoundexception/Item.java | 5 +- .../entitynotfoundexception/User.java | 4 +- .../detachedentity/entity/Comment.java | 10 +-- .../exception/detachedentity/entity/Post.java | 8 +- .../lazyinitialization/entity/Role.java | 12 +-- .../lazyinitialization/entity/User.java | 16 ++-- .../persistentobject/entity/Article.java | 10 +-- .../persistentobject/entity/Author.java | 11 ++- .../persistentobject/entity/Book.java | 11 ++- .../transientobject/entity/Address.java | 20 ++--- .../transientobject/entity/Author.java | 17 ++-- .../transientobject/entity/Book.java | 17 ++-- .../transientobject/entity/Department.java | 16 ++-- .../transientobject/entity/Employee.java | 17 ++-- .../transientobject/entity/User.java | 23 +++--- ...ntityNotFoundExceptionIntegrationTest.java | 8 +- .../DetachedEntityUnitTest.java | 7 +- persistence-modules/hibernate-jpa/pom.xml | 12 +-- .../converters/PersonNameConverter.java | 4 +- .../hibernate/entities/Department.java | 2 +- .../hibernate/entities/DeptEmployee.java | 12 +-- .../entitymanager/getreference/Game.java | 4 +- .../entitymanager/getreference/Player.java | 6 +- .../jpabootstrap/application/Application.java | 5 +- .../config/HibernatePersistenceUnitInfo.java | 10 +-- .../config/JpaEntityManagerFactory.java | 6 +- .../hibernate/jpabootstrap/entities/User.java | 10 +-- .../service/EmployeeSearchServiceImpl.java | 14 ++-- .../onetoone/foreignkeybased/Address.java | 14 ++-- .../onetoone/foreignkeybased/User.java | 18 ++--- .../onetoone/jointablebased/Employee.java | 20 ++--- .../onetoone/jointablebased/WorkStation.java | 14 ++-- .../onetoone/sharedkeybased/Address.java | 14 ++-- .../onetoone/sharedkeybased/User.java | 18 ++--- .../OptimisticLockingCourse.java | 2 +- .../OptimisticLockingStudent.java | 2 +- .../hibernate/pessimisticlocking/Address.java | 2 +- .../pessimisticlocking/Customer.java | 2 +- .../pessimisticlocking/Individual.java | 8 +- .../PessimisticLockingCourse.java | 2 +- .../PessimisticLockingEmployee.java | 2 +- .../PessimisticLockingStudent.java | 2 +- .../com/baeldung/hibernate/pojo/Movie.java | 6 +- .../com/baeldung/hibernate/pojo/Person.java | 8 +- .../com/baeldung/hibernate/pojo/Post.java | 8 +- .../com/baeldung/hibernate/pojo/Student.java | 8 +- .../hibernate/serializable/Account.java | 8 +- .../hibernate/serializable/Email.java | 4 +- .../baeldung/hibernate/serializable/User.java | 4 +- .../hibernate/serializable/UserId.java | 2 +- .../persistencecontext/entity/User.java | 6 +- ...ExtendedPersistenceContextUserService.java | 12 +-- ...ansctionPersistenceContextUserService.java | 12 +-- .../main/resources/META-INF/persistence.xml | 81 ++++++++++++------- .../GetReferenceH2IntegrationTest.java | 44 +++++----- .../GetReferenceMySQLManualTest.java | 6 +- .../GetReferencePostgreSQLManualTest.java | 6 +- .../EmployeeSearchServiceIntegrationTest.java | 4 +- .../OptimisticLockingIntegrationTest.java | 6 +- ...asicPessimisticLockingIntegrationTest.java | 6 +- .../PessimisticLockScopesIntegrationTest.java | 12 +-- .../JPASerializableIntegrationTest.java | 11 ++- .../TransactionIntegrationTest.java | 2 - .../PersistenceContextIntegrationTest.java | 4 +- .../hibernate-mapping-2/pom.xml | 24 +----- .../baeldung/manytomany/model/Employee.java | 20 ++--- .../baeldung/manytomany/model/Project.java | 12 +-- persistence-modules/pom.xml | 55 +++++++------ pom.xml | 13 ++- 84 files changed, 441 insertions(+), 478 deletions(-) diff --git a/.gitignore b/.gitignore index d68ab98349..7725bf202e 100644 --- a/.gitignore +++ b/.gitignore @@ -89,6 +89,7 @@ spring-soap/src/main/java/com/baeldung/springsoap/gen/ /report-*.json transaction.log *-shell.log +customers.xml apache-cxf/cxf-aegis/baeldung.xml testing-modules/report-*.json diff --git a/persistence-modules/activejdbc/pom.xml b/persistence-modules/activejdbc/pom.xml index 5fdf27a679..a661fc3abb 100644 --- a/persistence-modules/activejdbc/pom.xml +++ b/persistence-modules/activejdbc/pom.xml @@ -74,9 +74,9 @@ - 2.0 + 3.4-j11 development.test,development - 5.1.34 + 8.0.32 \ No newline at end of file diff --git a/persistence-modules/activejdbc/src/main/java/com/baeldung/ActiveJDBCApp.java b/persistence-modules/activejdbc/src/main/java/com/baeldung/ActiveJDBCApp.java index 8906d3e759..ea600b9721 100644 --- a/persistence-modules/activejdbc/src/main/java/com/baeldung/ActiveJDBCApp.java +++ b/persistence-modules/activejdbc/src/main/java/com/baeldung/ActiveJDBCApp.java @@ -4,6 +4,7 @@ package com.baeldung; import com.baeldung.model.Employee; import com.baeldung.model.Role; import org.javalite.activejdbc.Base; +import org.javalite.activejdbc.DB; import org.javalite.activejdbc.LazyList; import org.javalite.activejdbc.Model; @@ -11,8 +12,7 @@ public class ActiveJDBCApp { public static void main( String[] args ) { - try { - Base.open(); + try(final DB open = Base.open()) { ActiveJDBCApp app = new ActiveJDBCApp(); app.create(); app.update(); diff --git a/persistence-modules/core-java-persistence/pom.xml b/persistence-modules/core-java-persistence/pom.xml index 5cc1df483f..e8add07fbf 100644 --- a/persistence-modules/core-java-persistence/pom.xml +++ b/persistence-modules/core-java-persistence/pom.xml @@ -52,14 +52,21 @@ spring-boot-starter ${springframework.boot.spring-boot-starter.version} + + mysql + mysql-connector-java + ${mysql-connector.version} + runtime + - 2.4.0 - 3.2.0 - 0.9.5.2 - 1.5.8.RELEASE - 4.3.4.RELEASE + 2.9.0 + 5.0.1 + 0.9.5.5 + 3.0.4 + 6.0.6 + 8.0.32 \ No newline at end of file diff --git a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcmetadata/DatabaseConfig.java b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcmetadata/DatabaseConfig.java index 8ad689041e..44cfc75a2b 100644 --- a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcmetadata/DatabaseConfig.java +++ b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcmetadata/DatabaseConfig.java @@ -1,13 +1,14 @@ package com.baeldung.jdbcmetadata; -import org.apache.log4j.Logger; - import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class DatabaseConfig { - private static final Logger LOG = Logger.getLogger(DatabaseConfig.class); + private static final Logger LOG = LoggerFactory.getLogger(DatabaseConfig.class); private Connection connection; @@ -17,7 +18,7 @@ public class DatabaseConfig { String url = "jdbc:h2:mem:testdb"; connection = DriverManager.getConnection(url, "sa", ""); } catch (ClassNotFoundException | SQLException e) { - LOG.error(e); + LOG.error(e.getMessage()); } } @@ -35,7 +36,7 @@ public class DatabaseConfig { connection.createStatement().executeUpdate("create table CUSTOMER (ID int primary key auto_increment, NAME VARCHAR(45))"); connection.createStatement().executeUpdate("create table CUST_ADDRESS (ID VARCHAR(36), CUST_ID int, ADDRESS VARCHAR(45), FOREIGN KEY (CUST_ID) REFERENCES CUSTOMER(ID))"); } catch (SQLException e) { - LOG.error(e); + LOG.error(e.getMessage()); } } @@ -43,7 +44,7 @@ public class DatabaseConfig { try { connection.createStatement().executeUpdate("CREATE VIEW CUSTOMER_VIEW AS SELECT * FROM CUSTOMER"); } catch (SQLException e) { - LOG.error(e); + LOG.error(e.getMessage()); } } } diff --git a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcmetadata/JdbcMetadataApplication.java b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcmetadata/JdbcMetadataApplication.java index 591a14f3b5..f85f227381 100644 --- a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcmetadata/JdbcMetadataApplication.java +++ b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcmetadata/JdbcMetadataApplication.java @@ -1,12 +1,13 @@ package com.baeldung.jdbcmetadata; -import org.apache.log4j.Logger; - import java.sql.SQLException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class JdbcMetadataApplication { - private static final Logger LOG = Logger.getLogger(JdbcMetadataApplication.class); + private static final Logger LOG = LoggerFactory.getLogger(JdbcMetadataApplication.class); public static void main(String[] args) { DatabaseConfig databaseConfig = new DatabaseConfig(); diff --git a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcrowset/DatabaseConfiguration.java b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcrowset/DatabaseConfiguration.java index 9cfcff468e..a53c82d3da 100644 --- a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcrowset/DatabaseConfiguration.java +++ b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcrowset/DatabaseConfiguration.java @@ -5,10 +5,6 @@ import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; -import javax.sql.rowset.JdbcRowSet; -import javax.sql.rowset.RowSetFactory; -import javax.sql.rowset.RowSetProvider; - import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Configuration; diff --git a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcrowset/JdbcRowsetApplication.java b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcrowset/JdbcRowsetApplication.java index 72c462ac42..163b3a3b58 100644 --- a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcrowset/JdbcRowsetApplication.java +++ b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/jdbcrowset/JdbcRowsetApplication.java @@ -7,8 +7,6 @@ import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; -import com.sun.rowset.*; - import javax.sql.rowset.CachedRowSet; import javax.sql.rowset.FilteredRowSet; import javax.sql.rowset.JdbcRowSet; @@ -25,7 +23,7 @@ public class JdbcRowsetApplication { public static void main(String[] args) throws Exception { SpringApplication.run(JdbcRowsetApplication.class, args); - Statement stmt = null; + Statement stmt; try { Connection conn = DatabaseConfiguration.geth2Connection(); @@ -41,8 +39,7 @@ public class JdbcRowsetApplication { DatabaseConfiguration.initDatabase(stmt); // JdbcRowSet Example String sql = "SELECT * FROM customers"; - JdbcRowSet jdbcRS; - jdbcRS = new JdbcRowSetImpl(conn); + JdbcRowSet jdbcRS = RowSetProvider.newFactory().createJdbcRowSet(); jdbcRS.setType(ResultSet.TYPE_SCROLL_INSENSITIVE); jdbcRS.setCommand(sql); jdbcRS.execute(); @@ -58,7 +55,8 @@ public class JdbcRowsetApplication { String username = "sa"; String password = ""; String url = "jdbc:h2:mem:testdb"; - CachedRowSet crs = new CachedRowSetImpl(); + RowSetFactory aFactory = RowSetProvider.newFactory(); + CachedRowSet crs = aFactory.createCachedRowSet(); crs.setUsername(username); crs.setPassword(password); crs.setUrl(url); @@ -74,7 +72,7 @@ public class JdbcRowsetApplication { } // WebRowSet example - WebRowSet wrs = new WebRowSetImpl(); + WebRowSet wrs = RowSetProvider.newFactory().createWebRowSet(); wrs.setUsername(username); wrs.setPassword(password); wrs.setUrl(url); @@ -84,14 +82,14 @@ public class JdbcRowsetApplication { wrs.writeXml(ostream); // JoinRowSet example - CachedRowSetImpl customers = new CachedRowSetImpl(); + CachedRowSet customers = aFactory.createCachedRowSet(); customers.setUsername(username); customers.setPassword(password); customers.setUrl(url); customers.setCommand(sql); customers.execute(); - CachedRowSetImpl associates = new CachedRowSetImpl(); + CachedRowSet associates = aFactory.createCachedRowSet(); associates.setUsername(username); associates.setPassword(password); associates.setUrl(url); @@ -99,7 +97,7 @@ public class JdbcRowsetApplication { associates.setCommand(associatesSQL); associates.execute(); - JoinRowSet jrs = new JoinRowSetImpl(); + JoinRowSet jrs = RowSetProvider.newFactory().createJoinRowSet(); final String ID = "id"; final String NAME = "name"; jrs.addRowSet(customers, ID); diff --git a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbcrowset/JdbcRowSetLiveTest.java b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbcrowset/JdbcRowSetLiveTest.java index ebfb4df102..2b2b35c423 100644 --- a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbcrowset/JdbcRowSetLiveTest.java +++ b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/jdbcrowset/JdbcRowSetLiveTest.java @@ -19,11 +19,6 @@ import javax.sql.rowset.WebRowSet; import org.junit.Before; import org.junit.Test; -import com.sun.rowset.CachedRowSetImpl; -import com.sun.rowset.JdbcRowSetImpl; -import com.sun.rowset.JoinRowSetImpl; -import com.sun.rowset.WebRowSetImpl; - public class JdbcRowSetLiveTest { Statement stmt = null; String username = "sa"; @@ -51,9 +46,10 @@ public class JdbcRowSetLiveTest { public void createJdbcRowSet_SelectCustomers_ThenCorrect() throws Exception { String sql = "SELECT * FROM customers"; - JdbcRowSet jdbcRS; - Connection conn = DatabaseConfiguration.geth2Connection(); - jdbcRS = new JdbcRowSetImpl(conn); + JdbcRowSet jdbcRS = RowSetProvider.newFactory().createJdbcRowSet(); + jdbcRS.setUrl("jdbc:h2:mem:testdb"); + jdbcRS.setUsername("sa"); + jdbcRS.setPassword(""); jdbcRS.setType(ResultSet.TYPE_SCROLL_INSENSITIVE); jdbcRS.setCommand(sql); jdbcRS.execute(); @@ -71,7 +67,7 @@ public class JdbcRowSetLiveTest { @Test public void createCachedRowSet_DeleteRecord_ThenCorrect() throws Exception { - CachedRowSet crs = new CachedRowSetImpl(); + CachedRowSet crs = RowSetProvider.newFactory().createCachedRowSet(); crs.setUsername(username); crs.setPassword(password); crs.setUrl(url); @@ -91,7 +87,7 @@ public class JdbcRowSetLiveTest { @Test public void createWebRowSet_SelectCustomers_WritetoXML_ThenCorrect() throws SQLException, IOException { - WebRowSet wrs = new WebRowSetImpl(); + WebRowSet wrs = RowSetProvider.newFactory().createWebRowSet(); wrs.setUsername(username); wrs.setPassword(password); wrs.setUrl(url); @@ -105,14 +101,14 @@ public class JdbcRowSetLiveTest { @Test public void createCachedRowSets_DoJoinRowSet_ThenCorrect() throws Exception { - CachedRowSetImpl customers = new CachedRowSetImpl(); + CachedRowSet customers = RowSetProvider.newFactory().createCachedRowSet(); customers.setUsername(username); customers.setPassword(password); customers.setUrl(url); customers.setCommand(sql); customers.execute(); - CachedRowSetImpl associates = new CachedRowSetImpl(); + CachedRowSet associates = RowSetProvider.newFactory().createCachedRowSet(); associates.setUsername(username); associates.setPassword(password); associates.setUrl(url); @@ -120,7 +116,7 @@ public class JdbcRowSetLiveTest { associates.setCommand(associatesSQL); associates.execute(); - JoinRowSet jrs = new JoinRowSetImpl(); + JoinRowSet jrs = RowSetProvider.newFactory().createJoinRowSet(); final String ID = "id"; final String NAME = "name"; jrs.addRowSet(customers, ID); diff --git a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/JdbcLiveTest.java b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/JdbcLiveTest.java index c13f94f12a..fe00ca28dc 100644 --- a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/JdbcLiveTest.java +++ b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/JdbcLiveTest.java @@ -1,9 +1,10 @@ package com.baeldung.spring.jdbc; -import org.apache.log4j.Logger; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.sql.CallableStatement; import java.sql.Connection; @@ -24,7 +25,7 @@ import static org.junit.Assert.assertTrue; public class JdbcLiveTest { - private static final Logger LOG = Logger.getLogger(JdbcLiveTest.class); + private static final Logger LOG = LoggerFactory.getLogger(JdbcLiveTest.class); private Connection con; diff --git a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/ResultSetLiveTest.java b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/ResultSetLiveTest.java index 853e78a68d..c77e314141 100644 --- a/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/ResultSetLiveTest.java +++ b/persistence-modules/core-java-persistence/src/test/java/com/baeldung/spring/jdbc/ResultSetLiveTest.java @@ -13,7 +13,6 @@ import java.sql.Statement; import java.util.ArrayList; import java.util.List; -import org.apache.log4j.Logger; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.FixMethodOrder; @@ -25,8 +24,6 @@ import junit.framework.Assert; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ResultSetLiveTest { - private static final Logger logger = Logger.getLogger(ResultSetLiveTest.class); - private final Employee expectedEmployee1 = new Employee(1, "John", 1000.0, "Developer"); private final Employee updatedEmployee1 = new Employee(1, "John", 1100.0, "Developer"); diff --git a/persistence-modules/hbase/pom.xml b/persistence-modules/hbase/pom.xml index e38b73e137..3e6cfe27be 100644 --- a/persistence-modules/hbase/pom.xml +++ b/persistence-modules/hbase/pom.xml @@ -33,7 +33,7 @@ - 1.3.1 + 2.5.3 \ No newline at end of file diff --git a/persistence-modules/hbase/src/main/java/com/baeldung/hbase/HbaseClientExample.java b/persistence-modules/hbase/src/main/java/com/baeldung/hbase/HbaseClientExample.java index 5546f15e36..3a137a6019 100644 --- a/persistence-modules/hbase/src/main/java/com/baeldung/hbase/HbaseClientExample.java +++ b/persistence-modules/hbase/src/main/java/com/baeldung/hbase/HbaseClientExample.java @@ -1,7 +1,5 @@ package com.baeldung.hbase; - -import com.google.protobuf.ServiceException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HBaseConfiguration; @@ -13,11 +11,11 @@ import java.io.IOException; //install hbase locally & hbase master start public class HbaseClientExample { - public static void main(String[] args) throws IOException, ServiceException { + public static void main(String[] args) throws IOException { new HbaseClientExample().connect(); } - private void connect() throws IOException, ServiceException { + private void connect() throws IOException { Configuration config = HBaseConfiguration.create(); String path = this.getClass().getClassLoader().getResource("hbase-site.xml").getPath(); @@ -25,7 +23,7 @@ public class HbaseClientExample { config.addResource(new Path(path)); try { - HBaseAdmin.checkHBaseAvailable(config); + HBaseAdmin.available(config); } catch (MasterNotRunningException e) { System.out.println("HBase is not running." + e.getMessage()); return; diff --git a/persistence-modules/hibernate-exceptions/pom.xml b/persistence-modules/hibernate-exceptions/pom.xml index 4bef688715..670ff4cdb8 100644 --- a/persistence-modules/hibernate-exceptions/pom.xml +++ b/persistence-modules/hibernate-exceptions/pom.xml @@ -24,11 +24,6 @@ hibernate-core ${hibernate.version} - - javax.xml.bind - jaxb-api - ${jaxb.version} - com.h2database h2 @@ -37,8 +32,7 @@ - 2.4.0 - 2.3.0 + 2.7.1 2.1.214 diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Category.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Category.java index 25d31d50c7..cab06ae9cf 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Category.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Category.java @@ -1,6 +1,6 @@ package com.baeldung.hibernate.entitynotfoundexception; -import javax.persistence.*; +import jakarta.persistence.*; import java.io.Serializable; import java.util.ArrayList; import java.util.List; diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java index 3abed00eb8..2d07178aaf 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/Item.java @@ -1,9 +1,6 @@ package com.baeldung.hibernate.entitynotfoundexception; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; - -import javax.persistence.*; +import jakarta.persistence.*; import java.io.Serializable; @Entity diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/User.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/User.java index d89047195c..8351c5df96 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/User.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/entitynotfoundexception/User.java @@ -1,7 +1,7 @@ package com.baeldung.hibernate.entitynotfoundexception; -import javax.persistence.Entity; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; @Entity public class User { diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/detachedentity/entity/Comment.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/detachedentity/entity/Comment.java index 4a3e9739e2..e73adfef6b 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/detachedentity/entity/Comment.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/detachedentity/entity/Comment.java @@ -1,10 +1,10 @@ package com.baeldung.hibernate.exception.detachedentity.entity; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.ManyToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; @Entity public class Comment { diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/detachedentity/entity/Post.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/detachedentity/entity/Post.java index 7d95b41948..155a1bfe69 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/detachedentity/entity/Post.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/detachedentity/entity/Post.java @@ -1,9 +1,9 @@ package com.baeldung.hibernate.exception.detachedentity.entity; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; @Entity public class Post { diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/entity/Role.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/entity/Role.java index c15e674c52..5e613004a3 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/entity/Role.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/entity/Role.java @@ -1,11 +1,11 @@ package com.baeldung.hibernate.exception.lazyinitialization.entity; -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 jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; @Entity @Table(name = "role") diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/entity/User.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/entity/User.java index 5bd7e00801..ffae05c0a0 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/entity/User.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/lazyinitialization/entity/User.java @@ -3,14 +3,14 @@ package com.baeldung.hibernate.exception.lazyinitialization.entity; import java.util.HashSet; import java.util.Set; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; @Entity @Table(name = "user") diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Article.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Article.java index 3c9c7c5b31..eb697334ae 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Article.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Article.java @@ -1,10 +1,10 @@ package com.baeldung.hibernate.exception.persistentobject.entity; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.ManyToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; @Entity public class Article { diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Author.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Author.java index fa6aaa9abe..f8dcb82b7e 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Author.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Author.java @@ -2,12 +2,11 @@ package com.baeldung.hibernate.exception.persistentobject.entity; import java.util.List; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Book.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Book.java index 342da27c77..986c7f061f 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Book.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/persistentobject/entity/Book.java @@ -1,11 +1,10 @@ package com.baeldung.hibernate.exception.persistentobject.entity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; @Entity public class Book { diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Address.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Address.java index e450fc3c18..8d1208e036 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Address.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Address.java @@ -1,18 +1,12 @@ package com.baeldung.hibernate.exception.transientobject.entity; -import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; @Entity @Table(name = "address") diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Author.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Author.java index f1a88daa36..271e810002 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Author.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Author.java @@ -3,15 +3,14 @@ package com.baeldung.hibernate.exception.transientobject.entity; import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.Table; import java.util.HashSet; import java.util.Set; diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Book.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Book.java index 91728430ea..0734cccff1 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Book.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Book.java @@ -4,15 +4,14 @@ package com.baeldung.hibernate.exception.transientobject.entity; import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToMany; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.Table; import java.util.HashSet; import java.util.Set; diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Department.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Department.java index 4b8fa69964..5bd9a109ab 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Department.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Department.java @@ -1,13 +1,13 @@ package com.baeldung.hibernate.exception.transientobject.entity; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import java.util.HashSet; import java.util.Set; diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Employee.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Employee.java index 56443cce70..6a2ec8b938 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Employee.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/Employee.java @@ -4,15 +4,14 @@ package com.baeldung.hibernate.exception.transientobject.entity; import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; @Entity @Table(name = "employee") diff --git a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/User.java b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/User.java index eff1a88b51..cf56afd8b9 100644 --- a/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/User.java +++ b/persistence-modules/hibernate-exceptions/src/main/java/com/baeldung/hibernate/exception/transientobject/entity/User.java @@ -1,19 +1,14 @@ package com.baeldung.hibernate.exception.transientobject.entity; -import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; @Entity @Table(name = "user") diff --git a/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/entitynotfoundexception/EntityNotFoundExceptionIntegrationTest.java b/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/entitynotfoundexception/EntityNotFoundExceptionIntegrationTest.java index bcb4e3eb95..f339afd536 100644 --- a/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/entitynotfoundexception/EntityNotFoundExceptionIntegrationTest.java +++ b/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/entitynotfoundexception/EntityNotFoundExceptionIntegrationTest.java @@ -4,10 +4,10 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.EntityNotFoundException; -import javax.persistence.Persistence; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.EntityNotFoundException; +import jakarta.persistence.Persistence; import java.io.IOException; public class EntityNotFoundExceptionIntegrationTest { diff --git a/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java b/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java index afb0efae77..c10b319319 100644 --- a/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java +++ b/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/exception/detachedentity/DetachedEntityUnitTest.java @@ -3,13 +3,12 @@ package com.baeldung.hibernate.exception.detachedentity; import com.baeldung.hibernate.exception.detachedentity.entity.Comment; import com.baeldung.hibernate.exception.detachedentity.entity.Post; -import org.assertj.core.api.Assertions; import org.hibernate.Session; import org.junit.After; import org.junit.Before; import org.junit.Test; -import javax.persistence.PersistenceException; +import jakarta.persistence.PersistenceException; import java.util.List; @@ -43,7 +42,7 @@ public class DetachedEntityUnitTest { assertThatThrownBy(() -> session.persist(detachedPost)) .isInstanceOf(PersistenceException.class) - .hasMessageContaining("org.hibernate.PersistentObjectException: detached entity passed to persist"); + .hasMessageContaining("`org.hibernate.PersistentObjectException` to JPA `PersistenceException` : detached entity passed to persist"); } @Test @@ -72,7 +71,7 @@ public class DetachedEntityUnitTest { assertThatThrownBy(() -> session.persist(detachedPost)) .isInstanceOf(PersistenceException.class) - .hasMessageContaining("org.hibernate.PersistentObjectException: detached entity passed to persist"); + .hasMessageContaining("`org.hibernate.PersistentObjectException` to JPA `PersistenceException` : detached entity passed to persist"); } @Test diff --git a/persistence-modules/hibernate-jpa/pom.xml b/persistence-modules/hibernate-jpa/pom.xml index f742290884..086e487eb9 100644 --- a/persistence-modules/hibernate-jpa/pom.xml +++ b/persistence-modules/hibernate-jpa/pom.xml @@ -83,11 +83,13 @@ - 5.3.7.Final - 8.0.13 - 2.2.3 - 2.1.7.RELEASE - 1.4.200 + 6.1.7.Final + 8.0.32 + 2.6.0 + 3.0.4 + 2.1.214 + 2.0.7 + 1.4.6 \ No newline at end of file diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/converters/PersonNameConverter.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/converters/PersonNameConverter.java index 506e674984..ec0e2f2e2c 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/converters/PersonNameConverter.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/converters/PersonNameConverter.java @@ -1,7 +1,7 @@ package com.baeldung.hibernate.converters; -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; +import jakarta.persistence.AttributeConverter; +import jakarta.persistence.Converter; import com.baeldung.hibernate.pojo.PersonName; diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entities/Department.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entities/Department.java index ff94f4f849..39e69a2b1c 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entities/Department.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entities/Department.java @@ -2,7 +2,7 @@ package com.baeldung.hibernate.entities; import java.util.List; -import javax.persistence.*; +import jakarta.persistence.*; @Entity public class Department { diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entities/DeptEmployee.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entities/DeptEmployee.java index 6510e70650..38519644c5 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entities/DeptEmployee.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entities/DeptEmployee.java @@ -1,13 +1,13 @@ package com.baeldung.hibernate.entities; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.ManyToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; @org.hibernate.annotations.NamedQueries({ @org.hibernate.annotations.NamedQuery(name = "DeptEmployee_FindByEmployeeNumber", query = "from DeptEmployee where employeeNumber = :employeeNo"), - @org.hibernate.annotations.NamedQuery(name = "DeptEmployee_FindAllByDesgination", query = "from DeptEmployee where designation = :designation"), + @org.hibernate.annotations.NamedQuery(name = "DeptEmployee_FindAllByDesgination", query = "from DeptEmployee where employeeNumber = :employeeNumber"), @org.hibernate.annotations.NamedQuery(name = "DeptEmployee_UpdateEmployeeDepartment", query = "Update DeptEmployee set department = :newDepartment where employeeNumber = :employeeNo"), @org.hibernate.annotations.NamedQuery(name = "DeptEmployee_FindAllByDepartment", query = "from DeptEmployee where department = :department", timeout = 1, fetchSize = 10) }) @org.hibernate.annotations.NamedNativeQueries({ @org.hibernate.annotations.NamedNativeQuery(name = "DeptEmployee_FindByEmployeeName", query = "select * from deptemployee emp where name=:name", resultClass = DeptEmployee.class), diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitymanager/getreference/Game.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitymanager/getreference/Game.java index 1de8de0327..5a6f9c7c6c 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitymanager/getreference/Game.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitymanager/getreference/Game.java @@ -1,7 +1,7 @@ package com.baeldung.hibernate.entitymanager.getreference; -import javax.persistence.Entity; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; @Entity public class Game { diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitymanager/getreference/Player.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitymanager/getreference/Player.java index 459a3a00ad..6e62aeda45 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitymanager/getreference/Player.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/entitymanager/getreference/Player.java @@ -1,8 +1,8 @@ package com.baeldung.hibernate.entitymanager.getreference; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.ManyToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; @Entity public class Player { diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/application/Application.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/application/Application.java index b547a60b06..6263df4237 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/application/Application.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/application/Application.java @@ -2,7 +2,7 @@ package com.baeldung.hibernate.jpabootstrap.application; import com.baeldung.hibernate.jpabootstrap.config.JpaEntityManagerFactory; import com.baeldung.hibernate.jpabootstrap.entities.User; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; public class Application { @@ -24,8 +24,7 @@ public class Application { } private static class EntityManagerHolder { - private static final EntityManager ENTITY_MANAGER = new JpaEntityManagerFactory( - new Class[]{User.class}).getEntityManager(); + private static final EntityManager ENTITY_MANAGER = new JpaEntityManagerFactory(new Class[]{User.class}).getEntityManager(); } public static EntityManager getJpaEntityManager() { diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/config/HibernatePersistenceUnitInfo.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/config/HibernatePersistenceUnitInfo.java index 3852b44b64..af01ea630c 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/config/HibernatePersistenceUnitInfo.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/config/HibernatePersistenceUnitInfo.java @@ -6,11 +6,11 @@ import java.util.Collections; import java.util.List; import java.util.Properties; import javax.sql.DataSource; -import javax.persistence.SharedCacheMode; -import javax.persistence.ValidationMode; -import javax.persistence.spi.ClassTransformer; -import javax.persistence.spi.PersistenceUnitInfo; -import javax.persistence.spi.PersistenceUnitTransactionType; +import jakarta.persistence.SharedCacheMode; +import jakarta.persistence.ValidationMode; +import jakarta.persistence.spi.ClassTransformer; +import jakarta.persistence.spi.PersistenceUnitInfo; +import jakarta.persistence.spi.PersistenceUnitTransactionType; import org.hibernate.jpa.HibernatePersistenceProvider; public class HibernatePersistenceUnitInfo implements PersistenceUnitInfo { diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/config/JpaEntityManagerFactory.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/config/JpaEntityManagerFactory.java index bc1932af6f..e115727d67 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/config/JpaEntityManagerFactory.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/config/JpaEntityManagerFactory.java @@ -7,10 +7,10 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.stream.Collectors; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import javax.sql.DataSource; -import javax.persistence.EntityManagerFactory; -import javax.persistence.spi.PersistenceUnitInfo; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.spi.PersistenceUnitInfo; import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; import org.hibernate.jpa.boot.internal.PersistenceUnitInfoDescriptor; diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/entities/User.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/entities/User.java index 86ca1dfa19..43c99f8d96 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/entities/User.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpabootstrap/entities/User.java @@ -1,10 +1,10 @@ package com.baeldung.hibernate.jpabootstrap.entities; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; @Entity @Table(name = "users") diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpacriteriabuilder/service/EmployeeSearchServiceImpl.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpacriteriabuilder/service/EmployeeSearchServiceImpl.java index e79168a451..9a3216b5eb 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpacriteriabuilder/service/EmployeeSearchServiceImpl.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/jpacriteriabuilder/service/EmployeeSearchServiceImpl.java @@ -2,13 +2,13 @@ package com.baeldung.hibernate.jpacriteriabuilder.service; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.TypedQuery; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaBuilder.In; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; -import javax.persistence.criteria.Subquery; +import jakarta.persistence.EntityManager; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaBuilder.In; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; +import jakarta.persistence.criteria.Subquery; import com.baeldung.hibernate.entities.Department; import com.baeldung.hibernate.entities.DeptEmployee; diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/Address.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/Address.java index e05eb46030..0c3238cf98 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/Address.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/Address.java @@ -1,12 +1,12 @@ package com.baeldung.hibernate.onetoone.foreignkeybased; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; @Entity @Table(name = "address") diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/User.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/User.java index dda972f29c..14c2a0a28c 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/User.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/foreignkeybased/User.java @@ -1,14 +1,14 @@ package com.baeldung.hibernate.onetoone.foreignkeybased; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; @Entity @Table(name = "users") diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/Employee.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/Employee.java index a0bc101b9f..fc8b9eefec 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/Employee.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/Employee.java @@ -1,15 +1,15 @@ package com.baeldung.hibernate.onetoone.jointablebased; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.OneToOne; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; @Entity @Table(name = "employee") diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/WorkStation.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/WorkStation.java index f530611f6e..0834b9f9d7 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/WorkStation.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/jointablebased/WorkStation.java @@ -1,13 +1,13 @@ package com.baeldung.hibernate.onetoone.jointablebased; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; @Entity @Table(name = "workstation") diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/Address.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/Address.java index e70c62e77b..d738b900bc 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/Address.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/Address.java @@ -1,12 +1,12 @@ package com.baeldung.hibernate.onetoone.sharedkeybased; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.MapsId; -import javax.persistence.OneToOne; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.MapsId; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; @Entity @Table(name = "address") diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/User.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/User.java index 605671a149..8ce767eaf7 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/User.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/onetoone/sharedkeybased/User.java @@ -1,15 +1,15 @@ package com.baeldung.hibernate.onetoone.sharedkeybased; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToOne; -import javax.persistence.PrimaryKeyJoinColumn; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToOne; +import jakarta.persistence.PrimaryKeyJoinColumn; +import jakarta.persistence.Table; @Entity @Table(name = "users") diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingCourse.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingCourse.java index 1af3e3e21b..b8212a049d 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingCourse.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingCourse.java @@ -1,6 +1,6 @@ package com.baeldung.hibernate.optimisticlocking; -import javax.persistence.*; +import jakarta.persistence.*; @Entity public class OptimisticLockingCourse { diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingStudent.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingStudent.java index b79212ae8d..22f11e37fb 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingStudent.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingStudent.java @@ -1,6 +1,6 @@ package com.baeldung.hibernate.optimisticlocking; -import javax.persistence.*; +import jakarta.persistence.*; import java.util.List; @Entity diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Address.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Address.java index c889cb6127..7c6d20df40 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Address.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Address.java @@ -1,6 +1,6 @@ package com.baeldung.hibernate.pessimisticlocking; -import javax.persistence.Embeddable; +import jakarta.persistence.Embeddable; @Embeddable public class Address { diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Customer.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Customer.java index cb73cbc958..9f36e3b308 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Customer.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Customer.java @@ -1,6 +1,6 @@ package com.baeldung.hibernate.pessimisticlocking; -import javax.persistence.*; +import jakarta.persistence.*; import java.util.List; @Entity diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Individual.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Individual.java index e491c09eb5..b954c9fdb2 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Individual.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/Individual.java @@ -1,9 +1,9 @@ package com.baeldung.hibernate.pessimisticlocking; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; @Entity @Inheritance(strategy = InheritanceType.JOINED) diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingCourse.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingCourse.java index aea7d5fc87..012f3d1d39 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingCourse.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingCourse.java @@ -1,6 +1,6 @@ package com.baeldung.hibernate.pessimisticlocking; -import javax.persistence.*; +import jakarta.persistence.*; @Entity public class PessimisticLockingCourse { diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingEmployee.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingEmployee.java index a1328cbdad..e5b00f3800 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingEmployee.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingEmployee.java @@ -1,6 +1,6 @@ package com.baeldung.hibernate.pessimisticlocking; -import javax.persistence.Entity; +import jakarta.persistence.Entity; import java.math.BigDecimal; @Entity diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingStudent.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingStudent.java index e6c5f476b4..c5634ebc24 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingStudent.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockingStudent.java @@ -1,6 +1,6 @@ package com.baeldung.hibernate.pessimisticlocking; -import javax.persistence.*; +import jakarta.persistence.*; import java.util.List; @Entity diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Movie.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Movie.java index 5fae7f6a97..7aeadd4501 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Movie.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Movie.java @@ -1,8 +1,8 @@ package com.baeldung.hibernate.pojo; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; @Entity @Table(name = "MOVIE") diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Person.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Person.java index 390a5954ed..d0c8b8aa2f 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Person.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Person.java @@ -1,9 +1,9 @@ package com.baeldung.hibernate.pojo; -import javax.persistence.Convert; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; +import jakarta.persistence.Convert; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; import com.baeldung.hibernate.converters.PersonNameConverter; diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Post.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Post.java index 25e51e35d0..66a68367d7 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Post.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Post.java @@ -1,9 +1,9 @@ package com.baeldung.hibernate.pojo; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.Table; @Entity @Table(name = "posts") diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Student.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Student.java index 9b26c117eb..263908a5fc 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Student.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/pojo/Student.java @@ -1,9 +1,9 @@ package com.baeldung.hibernate.pojo; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; @Entity public class Student { diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Account.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Account.java index b051809ee5..7070f21c45 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Account.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Account.java @@ -1,9 +1,9 @@ package com.baeldung.hibernate.serializable; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; @Entity public class Account { diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Email.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Email.java index 11e7c6f159..4ba902281a 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Email.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/Email.java @@ -1,7 +1,7 @@ package com.baeldung.hibernate.serializable; -import javax.persistence.Entity; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; import java.io.Serializable; @Entity diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/User.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/User.java index e7820fe52f..267155b4db 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/User.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/User.java @@ -1,7 +1,7 @@ package com.baeldung.hibernate.serializable; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; @Entity public class User { diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/UserId.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/UserId.java index 7d3d382f67..6fcbeafdd0 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/UserId.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/hibernate/serializable/UserId.java @@ -1,6 +1,6 @@ package com.baeldung.hibernate.serializable; -import javax.persistence.Embeddable; +import jakarta.persistence.Embeddable; import java.io.Serializable; @Embeddable diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/entity/User.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/entity/User.java index 7252ac46f5..afdbf067c3 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/entity/User.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/entity/User.java @@ -1,9 +1,9 @@ package com.baeldung.persistencecontext.entity; -import javax.persistence.Entity; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; -@Entity +@Entity(name = "users") public class User { @Id diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/service/ExtendedPersistenceContextUserService.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/service/ExtendedPersistenceContextUserService.java index ef25aac69f..7ad6aae745 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/service/ExtendedPersistenceContextUserService.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/service/ExtendedPersistenceContextUserService.java @@ -1,15 +1,15 @@ package com.baeldung.persistencecontext.service; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.PersistenceContextType; -import javax.transaction.Transactional; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import jakarta.persistence.PersistenceContextType; +import jakarta.transaction.Transactional; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import com.baeldung.persistencecontext.entity.User; -@Component +@Service public class ExtendedPersistenceContextUserService { @PersistenceContext(type = PersistenceContextType.EXTENDED) diff --git a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/service/TransctionPersistenceContextUserService.java b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/service/TransctionPersistenceContextUserService.java index 481defcf08..6b9fd1f14c 100644 --- a/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/service/TransctionPersistenceContextUserService.java +++ b/persistence-modules/hibernate-jpa/src/main/java/com/baeldung/persistencecontext/service/TransctionPersistenceContextUserService.java @@ -1,20 +1,20 @@ package com.baeldung.persistencecontext.service; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.transaction.Transactional; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import jakarta.transaction.Transactional; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import com.baeldung.persistencecontext.entity.User; -@Component +@Service public class TransctionPersistenceContextUserService { @PersistenceContext private EntityManager entityManager; - + @Transactional public User insertWithTransaction(User user) { entityManager.persist(user); diff --git a/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml b/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml index 12b41a4973..1669413289 100644 --- a/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/hibernate-jpa/src/main/resources/META-INF/persistence.xml @@ -8,12 +8,13 @@ com.baeldung.hibernate.pojo.Movie true - + - - - - + + + + + @@ -34,10 +35,14 @@ - - - - + + + + + + + + @@ -57,16 +62,20 @@ - - - - - + + + + + - - - - + + + + + + + + @@ -87,16 +96,20 @@ - - - - - + + + + + - - - - + + + + + + + + @@ -113,10 +126,16 @@ - - - - + + + + + + + + + + diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java index e8e6aeed7c..02744c8ee5 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceH2IntegrationTest.java @@ -5,9 +5,9 @@ import ch.qos.logback.classic.Logger; import org.junit.jupiter.api.*; import org.slf4j.LoggerFactory; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.io.PrintStream; @@ -87,8 +87,8 @@ public class GetReferenceH2IntegrationTest { }); StringBuilder expected = new StringBuilder(); - expected.append("Hibernate: select game0_.id as id1_0_0_, game0_.name as name2_0_0_ from Game game0_ where game0_.id=?\n"); - expected.append("Hibernate: update Game set name=? where id=?\n"); + expected.append("Hibernate: select g1_0.id,g1_0.name from Game g1_0 where g1_0.id=?" + System.lineSeparator()); + expected.append("Hibernate: update Game set name=? where id=?" + System.lineSeparator()); assertEquals(expected.toString(), output.toString()); } @@ -104,8 +104,8 @@ public class GetReferenceH2IntegrationTest { }); StringBuilder expected = new StringBuilder(); - expected.append("Hibernate: select game0_.id as id1_0_0_, game0_.name as name2_0_0_ from Game game0_ where game0_.id=?\n"); - expected.append("Hibernate: update Game set name=? where id=?\n"); + expected.append("Hibernate: select g1_0.id,g1_0.name from Game g1_0 where g1_0.id=?" + System.lineSeparator()); + expected.append("Hibernate: update Game set name=? where id=?" + System.lineSeparator()); assertEquals(expected.toString(), output.toString()); } @@ -120,10 +120,9 @@ public class GetReferenceH2IntegrationTest { StringBuilder expected = new StringBuilder(); expected.append("Hibernate: select "); - expected.append("player0_.id as id1_1_0_, player0_.game_id as game_id3_1_0_, "); - expected.append("player0_.name as name2_1_0_, game1_.id as id1_0_1_, game1_.name as name2_0_1_ "); - expected.append("from Player player0_ left outer join Game game1_ on player0_.game_id=game1_.id where player0_.id=?\n"); - expected.append("Hibernate: delete from Player where id=?\n"); + expected.append("p1_0.id,g1_0.id,g1_0.name,p1_0.name "); + expected.append("from Player p1_0 left join Game g1_0 on g1_0.id=p1_0.game_id where p1_0.id=?" + System.lineSeparator()); + expected.append("Hibernate: delete from Player where id=?" + System.lineSeparator()); assertEquals(expected.toString(), output.toString()); } @@ -138,10 +137,9 @@ public class GetReferenceH2IntegrationTest { StringBuilder expected = new StringBuilder(); expected.append("Hibernate: select "); - expected.append("player0_.id as id1_1_0_, player0_.game_id as game_id3_1_0_, "); - expected.append("player0_.name as name2_1_0_, game1_.id as id1_0_1_, game1_.name as name2_0_1_ "); - expected.append("from Player player0_ left outer join Game game1_ on player0_.game_id=game1_.id where player0_.id=?\n"); - expected.append("Hibernate: delete from Player where id=?\n"); + expected.append("p1_0.id,g1_0.id,g1_0.name,p1_0.name "); + expected.append("from Player p1_0 left join Game g1_0 on g1_0.id=p1_0.game_id where p1_0.id=?" + System.lineSeparator()); + expected.append("Hibernate: delete from Player where id=?" + System.lineSeparator()); assertEquals(expected.toString(), output.toString()); } @@ -159,12 +157,11 @@ public class GetReferenceH2IntegrationTest { })); StringBuilder expected = new StringBuilder(); - expected.append("Hibernate: select game0_.id as id1_0_0_, game0_.name as name2_0_0_ from Game game0_ where game0_.id=?\n"); + expected.append("Hibernate: select g1_0.id,g1_0.name from Game g1_0 where g1_0.id=?" + System.lineSeparator()); expected.append("Hibernate: select "); - expected.append("player0_.id as id1_1_0_, player0_.game_id as game_id3_1_0_, "); - expected.append("player0_.name as name2_1_0_, game1_.id as id1_0_1_, game1_.name as name2_0_1_ "); - expected.append("from Player player0_ left outer join Game game1_ on player0_.game_id=game1_.id where player0_.id=?\n"); - expected.append("Hibernate: update Player set game_id=?, name=? where id=?\n"); + expected.append("p1_0.id,g1_0.id,g1_0.name,p1_0.name "); + expected.append("from Player p1_0 left join Game g1_0 on g1_0.id=p1_0.game_id where p1_0.id=?" + System.lineSeparator()); + expected.append("Hibernate: update Player set game_id=?, name=? where id=?" + System.lineSeparator()); assertEquals(expected.toString(), output.toString()); } @@ -183,10 +180,9 @@ public class GetReferenceH2IntegrationTest { StringBuilder expected = new StringBuilder(); expected.append("Hibernate: select "); - expected.append("player0_.id as id1_1_0_, player0_.game_id as game_id3_1_0_, "); - expected.append("player0_.name as name2_1_0_, game1_.id as id1_0_1_, game1_.name as name2_0_1_ "); - expected.append("from Player player0_ left outer join Game game1_ on player0_.game_id=game1_.id where player0_.id=?\n"); - expected.append("Hibernate: update Player set game_id=?, name=? where id=?\n"); + expected.append("p1_0.id,g1_0.id,g1_0.name,p1_0.name "); + expected.append("from Player p1_0 left join Game g1_0 on g1_0.id=p1_0.game_id where p1_0.id=?" + System.lineSeparator()); + expected.append("Hibernate: update Player set game_id=?, name=? where id=?" + System.lineSeparator()); assertEquals(expected.toString(), output.toString()); } diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceMySQLManualTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceMySQLManualTest.java index 2b7c5e8119..29be19dd68 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceMySQLManualTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferenceMySQLManualTest.java @@ -5,9 +5,9 @@ import ch.qos.logback.classic.Logger; import org.junit.jupiter.api.*; import org.slf4j.LoggerFactory; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.io.PrintStream; diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferencePostgreSQLManualTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferencePostgreSQLManualTest.java index 17f6b10b8a..20a0bca6f1 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferencePostgreSQLManualTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/entitymanager/getreference/GetReferencePostgreSQLManualTest.java @@ -5,9 +5,9 @@ import ch.qos.logback.classic.Logger; import org.junit.jupiter.api.*; import org.slf4j.LoggerFactory; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; import java.io.ByteArrayOutputStream; import java.io.OutputStream; import java.io.PrintStream; diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/jpacriteriabuilder/EmployeeSearchServiceIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/jpacriteriabuilder/EmployeeSearchServiceIntegrationTest.java index 2b12734a10..d9bffcfc08 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/jpacriteriabuilder/EmployeeSearchServiceIntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/jpacriteriabuilder/EmployeeSearchServiceIntegrationTest.java @@ -9,7 +9,7 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import org.hibernate.HibernateException; import org.hibernate.Session; @@ -81,7 +81,7 @@ public class EmployeeSearchServiceIntegrationTest { @Test public final void givenCriteriaQuery_whenSearchedUsingCriteriaBuilderWithListofAuthors_thenResultIsFilteredByAuthorNames() { - List titles = new ArrayList() { + List titles = new ArrayList<>() { { add("Manager"); add("Senior Manager"); diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingIntegrationTest.java index 37c490f297..2fa302e270 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingIntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/optimisticlocking/OptimisticLockingIntegrationTest.java @@ -3,9 +3,9 @@ package com.baeldung.hibernate.optimisticlocking; import java.io.IOException; import java.util.Arrays; -import javax.persistence.EntityManager; -import javax.persistence.LockModeType; -import javax.persistence.OptimisticLockException; +import jakarta.persistence.EntityManager; +import jakarta.persistence.LockModeType; +import jakarta.persistence.OptimisticLockException; import org.hibernate.SessionFactory; import org.junit.After; diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/pessimisticlocking/BasicPessimisticLockingIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/pessimisticlocking/BasicPessimisticLockingIntegrationTest.java index 4b9c7720fd..4085a98dad 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/pessimisticlocking/BasicPessimisticLockingIntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/pessimisticlocking/BasicPessimisticLockingIntegrationTest.java @@ -1,14 +1,14 @@ package com.baeldung.hibernate.pessimisticlocking; import com.baeldung.hibernate.HibernateUtil; -import com.vividsolutions.jts.util.Assert; +import org.locationtech.jts.util.Assert; import org.hibernate.SessionFactory; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import javax.persistence.*; +import jakarta.persistence.*; import java.io.IOException; import java.util.Arrays; @@ -46,7 +46,7 @@ public class BasicPessimisticLockingIntegrationTest { } @Test - public void givenRecordWithPessimisticReadQuery_whenQueryingNewOne_PessimisticLockExceptionThrown() throws IOException { + public void givenRecordWithPessimisticReadQuery_whenQueryingNewOne_PessimisticLockExceptionThrown() { try { EntityManager entityManager = getEntityManagerWithOpenTransaction(); Query query = entityManager.createQuery("from Student where studentId = :studentId"); diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockScopesIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockScopesIntegrationTest.java index 81cb7d95f8..c2f2326159 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockScopesIntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/pessimisticlocking/PessimisticLockScopesIntegrationTest.java @@ -6,9 +6,9 @@ import org.hibernate.SessionFactory; import org.junit.AfterClass; import org.junit.Test; -import javax.persistence.EntityManager; -import javax.persistence.LockModeType; -import javax.persistence.PessimisticLockScope; +import jakarta.persistence.EntityManager; +import jakarta.persistence.LockModeType; +import jakarta.persistence.PessimisticLockScope; import java.io.IOException; import java.math.BigDecimal; import java.util.Arrays; @@ -36,7 +36,7 @@ public class PessimisticLockScopesIntegrationTest { // EXTENDED SCOPE Map map = new HashMap<>(); - map.put("javax.persistence.lock.scope", PessimisticLockScope.EXTENDED); + map.put("jakarta.persistence", PessimisticLockScope.EXTENDED); EntityManager em3 = getEntityManagerWithOpenTransaction(); foundEmployee = em3.find(PessimisticLockingEmployee.class, 1L, LockModeType.PESSIMISTIC_WRITE, map); @@ -65,7 +65,7 @@ public class PessimisticLockScopesIntegrationTest { // EXTENDED SCOPE Map map = new HashMap<>(); - map.put("javax.persistence.lock.scope", PessimisticLockScope.EXTENDED); + map.put("jakarta.persistence", PessimisticLockScope.EXTENDED); EntityManager em3 = getEntityManagerWithOpenTransaction(); foundCustomer = em3.find(Customer.class, 1L, LockModeType.PESSIMISTIC_WRITE, map); @@ -96,7 +96,7 @@ public class PessimisticLockScopesIntegrationTest { // EXTENDED SCOPE Map map = new HashMap<>(); - map.put("javax.persistence.lock.scope", PessimisticLockScope.EXTENDED); + map.put("jakarta.persistence", PessimisticLockScope.EXTENDED); EntityManager em3 = getEntityManagerWithOpenTransaction(); foundCourse = em3.find(PessimisticLockingCourse.class, 1L, LockModeType.PESSIMISTIC_WRITE, map); diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java index 696bc23ab0..5512757889 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/serializable/JPASerializableIntegrationTest.java @@ -4,10 +4,9 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import javax.persistence.EntityManager; -import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; -import java.io.IOException; +import jakarta.persistence.EntityManager; +import jakarta.persistence.EntityManagerFactory; +import jakarta.persistence.Persistence; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -17,7 +16,7 @@ public class JPASerializableIntegrationTest { private static EntityManager entityManager; @Before - public void setUp() throws IOException { + public void setUp() { EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("com.baeldung.hibernate.serializable.h2_persistence_unit"); entityManager = entityManagerFactory.createEntityManager(); entityManager.getTransaction().begin(); @@ -63,7 +62,7 @@ public class JPASerializableIntegrationTest { entityManager.persist(account); entityManager.persist(account2); - List userAccounts = entityManager.createQuery("select a from Account a join fetch a.user where a.user.email = :email") + List userAccounts = entityManager.createQuery("select a from Account a join fetch a.user where a.user.email = :email", Account.class) .setParameter("email", email) .getResultList(); assertEquals(2, userAccounts.size()); diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/transaction/TransactionIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/transaction/TransactionIntegrationTest.java index 246a7d59f9..f64846ba59 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/transaction/TransactionIntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/hibernate/transaction/TransactionIntegrationTest.java @@ -2,7 +2,6 @@ package com.baeldung.hibernate.transaction; import com.baeldung.hibernate.HibernateUtil; import com.baeldung.hibernate.pojo.Post; -import com.baeldung.hibernate.transaction.PostService; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.junit.BeforeClass; @@ -10,7 +9,6 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; diff --git a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/persistencecontext/PersistenceContextIntegrationTest.java b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/persistencecontext/PersistenceContextIntegrationTest.java index b299dd5834..37e6e438d8 100644 --- a/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/persistencecontext/PersistenceContextIntegrationTest.java +++ b/persistence-modules/hibernate-jpa/src/test/java/com/baeldung/persistencecontext/PersistenceContextIntegrationTest.java @@ -4,8 +4,8 @@ import com.baeldung.persistencecontext.entity.User; import com.baeldung.persistencecontext.service.ExtendedPersistenceContextUserService; import com.baeldung.persistencecontext.service.TransctionPersistenceContextUserService; -import javax.persistence.EntityExistsException; -import javax.persistence.TransactionRequiredException; +import jakarta.persistence.EntityExistsException; +import jakarta.persistence.TransactionRequiredException; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/persistence-modules/hibernate-mapping-2/pom.xml b/persistence-modules/hibernate-mapping-2/pom.xml index 2a787a0e46..a56f67b202 100644 --- a/persistence-modules/hibernate-mapping-2/pom.xml +++ b/persistence-modules/hibernate-mapping-2/pom.xml @@ -55,32 +55,16 @@ h2 ${h2.version} - - com.sun.xml.bind - jaxb-core - ${com.sun.xml.version} - - - javax.xml.bind - jaxb-api - ${javax.xml.bind.version} - - - com.sun.xml.bind - jaxb-impl - ${com.sun.xml.version} - - 5.0.2.RELEASE - 1.10.6.RELEASE + 6.0.6 + 3.0.3 - 5.2.10.Final + 6.1.7.Final 9.0.0.M26 - 2.3.0.1 - 2.3.1 + 4.0.2 2.1.214 diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Employee.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Employee.java index 39671c21bc..cc745f9307 100644 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Employee.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Employee.java @@ -4,16 +4,16 @@ import java.io.Serializable; import java.util.HashSet; import java.util.Set; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.Table; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.Table; @Entity @Table(name = "Employee") diff --git a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Project.java b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Project.java index b5dc3cb856..b0ca7f06cb 100644 --- a/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Project.java +++ b/persistence-modules/hibernate-mapping-2/src/main/java/com/baeldung/manytomany/model/Project.java @@ -4,12 +4,12 @@ import java.io.Serializable; import java.util.HashSet; import java.util.Set; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.ManyToMany; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.Table; @Entity @Table(name = "Project") diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index d7ff51b487..85cf251d18 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -21,61 +21,60 @@ blaze-persistence core-java-persistence core-java-persistence-2 - deltaspike elasticsearch flyway flyway-repair hbase hibernate5 - hibernate-mapping + hibernate-mapping-2 - hibernate-ogm - hibernate-annotations + hibernate-exceptions hibernate-libraries hibernate-jpa - hibernate-queries - hibernate-enterprise + + influxdb - java-cassandra + java-cockroachdb java-jdbi - java-jpa - java-jpa-2 + + java-jpa-3 java-mongodb-2 java-mongodb-3 java-mongodb-queries - jnosql + jooq jpa-hibernate-cascade-type liquibase orientdb persistence-libraries - querydsl - r2dbc + + read-only-transactions - redis + solr - spring-boot-persistence-2 + spring-boot-persistence-3 spring-boot-mysql spring-boot-persistence spring-boot-persistence-h2 - spring-boot-persistence-mongodb + spring-data-arangodb spring-data-cassandra spring-data-cassandra-test - spring-data-cassandra-reactive + spring-data-cosmosdb - spring-data-couchbase-2 + spring-data-dynamodb - spring-data-eclipselink + spring-data-elasticsearch @@ -89,24 +88,24 @@ spring-data-jpa-query spring-data-jpa-query-2 spring-data-jpa-query-3 - spring-data-jpa-repo + spring-data-jpa-repo-2 spring-data-jdbc spring-data-keyvalue - spring-data-mongodb + spring-data-mongodb-2 spring-data-mongodb-reactive - spring-data-neo4j + spring-data-redis spring-data-rest-2 spring-data-rest-querydsl spring-data-solr - spring-hibernate-3 - spring-hibernate-5 - spring-jpa - spring-jpa-2 + + + spring-jdbc spring-jooq spring-mybatis @@ -115,8 +114,8 @@ - 5.2.17.Final - 42.2.20 + 6.1.7.Final + 42.5.4 2.3.4 1.16.3 diff --git a/pom.xml b/pom.xml index ca55866a42..ca50f630ae 100644 --- a/pom.xml +++ b/pom.xml @@ -367,8 +367,8 @@ muleesb - persistence-modules web-modules + persistence-modules/deltaspike @@ -562,8 +562,8 @@ lombok-modules muleesb - persistence-modules web-modules + persistence-modules/deltaspike @@ -821,9 +821,7 @@ libraries-testing maven-modules optaplanner - persistence-modules/sirix - persistence-modules/spring-data-cassandra-2 - persistence-modules/spring-data-jpa-repo-3 + persistence-modules quarkus-modules spring-reactive-modules spring-swagger-codegen/custom-validations-opeanpi-codegen @@ -1073,9 +1071,7 @@ libraries-testing maven-modules optaplanner - persistence-modules/sirix - persistence-modules/spring-data-cassandra-2 - persistence-modules/spring-data-jpa-repo-3 + persistence-modules quarkus-modules spring-reactive-modules spring-swagger-codegen/custom-validations-opeanpi-codegen @@ -1257,6 +1253,7 @@ 1.12.13 + 1.7.32 1.2.7