diff --git a/persistence-modules/atomikos/pom.xml b/persistence-modules/atomikos/pom.xml
index c1748f7dac..b535ff4dcc 100644
--- a/persistence-modules/atomikos/pom.xml
+++ b/persistence-modules/atomikos/pom.xml
@@ -18,6 +18,12 @@
transactions-jdbc
${atomikos-version}
+
+ com.atomikos
+ transactions-jta
+ ${atomikos-version}
+ jakarta
+
com.atomikos
transactions-jms
@@ -90,10 +96,10 @@
- 5.0.6
- 5.1.6.RELEASE
- 5.4.3.Final
- 1.11.23.RELEASE
+ 6.0.0
+ 6.1.2
+ 6.4.2.Final
+ 3.2.2
5.7.0
10.8.1.2
1.1
diff --git a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/config/Config.java b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/config/Config.java
index c6ef83c4ca..1aee108308 100644
--- a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/config/Config.java
+++ b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/config/Config.java
@@ -1,17 +1,14 @@
package com.baeldung.atomikos.spring.config;
-import java.util.Properties;
-
-import javax.transaction.SystemException;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-import org.springframework.transaction.jta.JtaTransactionManager;
-
import com.atomikos.icatch.jta.UserTransactionManager;
import com.atomikos.jdbc.AtomikosDataSourceBean;
import com.baeldung.atomikos.spring.Application;
+import jakarta.transaction.SystemException;
+import java.util.Properties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.transaction.jta.JtaTransactionManager;
@Configuration
@EnableTransactionManagement
@@ -46,7 +43,7 @@ public class Config {
}
@Bean(initMethod = "init", destroyMethod = "close")
- public UserTransactionManager userTransactionManager() throws SystemException {
+ public UserTransactionManager userTransactionManager() throws jakarta.transaction.SystemException {
UserTransactionManager userTransactionManager = new UserTransactionManager();
userTransactionManager.setTransactionTimeout(300);
userTransactionManager.setForceShutdown(true);
diff --git a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/Application.java b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/Application.java
index ad828bd2ca..434dd24e4a 100644
--- a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/Application.java
+++ b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/Application.java
@@ -29,13 +29,13 @@ public class Application {
String orderId = UUID.randomUUID()
.toString();
- Inventory inventory = inventoryRepository.findOne(productId);
+ Inventory inventory = inventoryRepository.getReferenceById(productId);
inventory.setBalance(inventory.getBalance() - amount);
inventoryRepository.save(inventory);
Order order = new Order();
order.setOrderId(orderId);
order.setProductId(productId);
- order.setAmount(new Long(amount));
+ order.setAmount( Long.valueOf(amount));
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set> violations = validator.validate(order);
diff --git a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/config/Config.java b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/config/Config.java
index 6716f19576..6ebf3aea8f 100644
--- a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/config/Config.java
+++ b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/config/Config.java
@@ -1,6 +1,6 @@
package com.baeldung.atomikos.spring.jpa.config;
-import javax.transaction.SystemException;
+import jakarta.transaction.SystemException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/Inventory.java b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/Inventory.java
index 999879218c..f23c307fea 100644
--- a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/Inventory.java
+++ b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/Inventory.java
@@ -1,8 +1,8 @@
package com.baeldung.atomikos.spring.jpa.inventory;
-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 = "INVENTORY")
diff --git a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryConfig.java b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryConfig.java
index 5301ad6ff2..6b05c380d0 100644
--- a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryConfig.java
+++ b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryConfig.java
@@ -2,7 +2,7 @@ package com.baeldung.atomikos.spring.jpa.inventory;
import java.util.Properties;
-import javax.persistence.EntityManagerFactory;
+import jakarta.persistence.EntityManagerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/Order.java b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/Order.java
index 3a580e6448..18980e31d4 100644
--- a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/Order.java
+++ b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/Order.java
@@ -1,8 +1,8 @@
package com.baeldung.atomikos.spring.jpa.order;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
import jakarta.validation.constraints.Max;
@Entity
diff --git a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderConfig.java b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderConfig.java
index b4274bb64c..431cfffe49 100644
--- a/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderConfig.java
+++ b/persistence-modules/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderConfig.java
@@ -2,7 +2,7 @@ package com.baeldung.atomikos.spring.jpa.order;
import java.util.Properties;
-import javax.persistence.EntityManagerFactory;
+import jakarta.persistence.EntityManagerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/persistence-modules/atomikos/src/test/java/com/baeldung/atomikos/spring/jpa/ApplicationUnitTest.java b/persistence-modules/atomikos/src/test/java/com/baeldung/atomikos/spring/jpa/ApplicationUnitTest.java
index e6a3c1982c..b1c426f83a 100644
--- a/persistence-modules/atomikos/src/test/java/com/baeldung/atomikos/spring/jpa/ApplicationUnitTest.java
+++ b/persistence-modules/atomikos/src/test/java/com/baeldung/atomikos/spring/jpa/ApplicationUnitTest.java
@@ -72,7 +72,7 @@ public class ApplicationUnitTest {
private static long getBalance(InventoryRepository inventoryRepository, String productId) throws Exception {
- return inventoryRepository.findOne(productId)
+ return inventoryRepository.getReferenceById(productId)
.getBalance();
}
diff --git a/persistence-modules/hibernate-enterprise/pom.xml b/persistence-modules/hibernate-enterprise/pom.xml
index caf7b37a41..f5c165b10c 100644
--- a/persistence-modules/hibernate-enterprise/pom.xml
+++ b/persistence-modules/hibernate-enterprise/pom.xml
@@ -15,7 +15,7 @@
- org.hibernate
+ org.hibernate.orm
hibernate-core
${hibernate.version}
@@ -25,7 +25,7 @@
${h2.version}
- org.hibernate
+ org.hibernate.orm
hibernate-spatial
${hibernate.version}
@@ -45,7 +45,7 @@
${mariaDB4j.version}
- org.hibernate
+ org.hibernate.orm
hibernate-testing
${hibernate.version}
@@ -82,6 +82,7 @@
8.2.0
2.6.0
0.9
+ 6.4.2.Final
\ No newline at end of file
diff --git a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/exception/HibernateExceptionUnitTest.java b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/exception/HibernateExceptionUnitTest.java
index 37c21d1899..2b711b9418 100644
--- a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/exception/HibernateExceptionUnitTest.java
+++ b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/exception/HibernateExceptionUnitTest.java
@@ -9,12 +9,16 @@ import java.util.List;
import jakarta.persistence.OptimisticLockException;
import jakarta.persistence.PersistenceException;
+import org.h2.jdbc.JdbcSQLDataException;
+import org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException;
+import org.h2.jdbc.JdbcSQLSyntaxErrorException;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.NonUniqueObjectException;
import org.hibernate.PropertyValueException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.StaleObjectStateException;
import org.hibernate.StaleStateException;
import org.hibernate.Transaction;
import org.hibernate.cfg.AvailableSettings;
@@ -132,8 +136,8 @@ public class HibernateExceptionUnitTest {
@Test
public void givenMissingTable_whenEntitySaved_thenSQLGrammarException() {
- thrown.expectCause(isA(SQLGrammarException.class));
- thrown.expectMessage("could not prepare statement");
+ thrown.expectCause(isA(JdbcSQLSyntaxErrorException.class));
+ thrown.expectMessage("Table \"PRODUCT\" not found (this database is empty); SQL statement");
Configuration cfg = getConfiguration();
cfg.addAnnotatedClass(Product.class);
@@ -161,8 +165,8 @@ public class HibernateExceptionUnitTest {
@Test
public void givenMissingTable_whenQueryExecuted_thenSQLGrammarException() {
- thrown.expectCause(isA(SQLGrammarException.class));
- thrown.expectMessage("could not prepare statement");
+ thrown.expectCause(isA(JdbcSQLSyntaxErrorException.class));
+ thrown.expectMessage("Table \"NON_EXISTING_TABLE\" not found");
Session session = sessionFactory.openSession();
NativeQuery query = session.createNativeQuery("select * from NON_EXISTING_TABLE", Product.class);
@@ -171,7 +175,7 @@ public class HibernateExceptionUnitTest {
@Test
public void whenDuplicateIdSaved_thenConstraintViolationException() {
- thrown.expectCause(isA(ConstraintViolationException.class));
+ thrown.expectCause(isA(JdbcSQLIntegrityConstraintViolationException.class));
thrown.expectMessage("could not execute statement");
Session session = null;
@@ -224,7 +228,7 @@ public class HibernateExceptionUnitTest {
public void givenEntityWithoutId_whenCallingSave_thenThrowIdentifierGenerationException() {
thrown.expect(isA(IdentifierGenerationException.class));
- thrown.expectMessage("ids for this class must be manually assigned before calling save(): com.baeldung.hibernate.exception.Product");
+ thrown.expectMessage("Identifier of entity 'com.baeldung.hibernate.exception.ProductEntity' must be manually assigned before calling 'persist()");
Session session = null;
Transaction transaction = null;
@@ -249,8 +253,8 @@ public class HibernateExceptionUnitTest {
@Test
public void givenQueryWithDataTypeMismatch_WhenQueryExecuted_thenDataException() {
- thrown.expectCause(isA(DataException.class));
- thrown.expectMessage("could not prepare statement");
+ thrown.expectCause(isA(JdbcSQLDataException.class));
+ thrown.expectMessage("Data conversion error converting \"wrongTypeId\"");
Session session = sessionFactory.openSession();
NativeQuery query = session.createNativeQuery("select * from PRODUCT where id='wrongTypeId'", Product.class);
@@ -291,7 +295,7 @@ public class HibernateExceptionUnitTest {
@Test
public void whenDeletingADeletedObject_thenOptimisticLockException() {
thrown.expect(isA(OptimisticLockException.class));
- thrown.expectMessage("Batch update returned unexpected row count from update");
+ thrown.expectMessage("Row was updated or deleted by another transaction");
thrown.expectCause(isA(StaleStateException.class));
Session session = null;
@@ -327,8 +331,8 @@ public class HibernateExceptionUnitTest {
@Test
public void whenUpdatingNonExistingObject_thenStaleStateException() {
- thrown.expectCause(isA(StaleStateException.class));
- thrown.expectMessage("Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed: update PRODUCT set description=?, name=? where id=?");
+ thrown.expectCause(isA(StaleObjectStateException.class));
+ thrown.expectMessage("Row was updated or deleted by another transaction");
Session session = null;
Transaction transaction = null;
@@ -409,9 +413,7 @@ public class HibernateExceptionUnitTest {
@Test
public void givenExistingEntity_whenIdUpdated_thenHibernateException() {
- thrown.expect(isA(PersistenceException.class));
- thrown.expectCause(isA(HibernateException.class));
- thrown.expectMessage("identifier of an instance of com.baeldung.hibernate.exception.Product was altered");
+ thrown.expect(isA(HibernateException.class));
Session session = null;
Transaction transaction = null;
diff --git a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/database/MapMultiTenantConnectionProvider.java b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/database/MapMultiTenantConnectionProvider.java
index 47abf6ff85..8458eefaeb 100644
--- a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/database/MapMultiTenantConnectionProvider.java
+++ b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/database/MapMultiTenantConnectionProvider.java
@@ -10,7 +10,7 @@ import org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionPr
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
@SuppressWarnings("serial")
-public class MapMultiTenantConnectionProvider extends AbstractMultiTenantConnectionProvider {
+public class MapMultiTenantConnectionProvider extends AbstractMultiTenantConnectionProvider {
private final Map connectionProviderMap = new HashMap<>();
@@ -26,6 +26,7 @@ public class MapMultiTenantConnectionProvider extends AbstractMultiTenantConnect
.next();
}
+
@Override
protected ConnectionProvider selectConnectionProvider(String tenantIdentifier) {
return connectionProviderMap.get(tenantIdentifier);
diff --git a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/schema/SchemaMultiTenantConnectionProvider.java b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/schema/SchemaMultiTenantConnectionProvider.java
index 67b838fdf1..aecfa23d0a 100644
--- a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/schema/SchemaMultiTenantConnectionProvider.java
+++ b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/schema/SchemaMultiTenantConnectionProvider.java
@@ -12,7 +12,7 @@ import org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionPr
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
@SuppressWarnings("serial")
-public class SchemaMultiTenantConnectionProvider extends AbstractMultiTenantConnectionProvider {
+public class SchemaMultiTenantConnectionProvider extends AbstractMultiTenantConnectionProvider {
private final ConnectionProvider connectionProvider;
diff --git a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java
index c3d2362339..921459ac46 100644
--- a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java
+++ b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/persistence/save/SaveMethodsIntegrationTest.java
@@ -179,7 +179,7 @@ public class SaveMethodsIntegrationTest {
.commit();
session.beginTransaction();
- assertNull(person.getId());
+ assertNotNull(person.getId());
assertNotNull(mergedPerson.getId());
}
diff --git a/persistence-modules/hibernate-exceptions/pom.xml b/persistence-modules/hibernate-exceptions/pom.xml
index 670ff4cdb8..7ab0308bd9 100644
--- a/persistence-modules/hibernate-exceptions/pom.xml
+++ b/persistence-modules/hibernate-exceptions/pom.xml
@@ -20,7 +20,7 @@
${hsqldb.version}
- org.hibernate
+ org.hibernate.orm
hibernate-core
${hibernate.version}
@@ -34,6 +34,7 @@
2.7.1
2.1.214
+ 6.4.2.Final
\ No newline at end of file
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 271e810002..e882083a70 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
@@ -26,9 +26,8 @@ public class Author {
@Column(name = "name")
private String name;
- @ManyToMany
@Cascade({ CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.PERSIST})
- @JoinColumn(name = "book_id")
+ @ManyToMany(mappedBy = "authors")
private Set books = new HashSet<>();
public void addBook(Book book) {
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 0734cccff1..6034455370 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
@@ -1,6 +1,7 @@
package com.baeldung.hibernate.exception.transientobject.entity;
+import jakarta.persistence.JoinTable;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
@@ -29,7 +30,7 @@ public class Book {
@ManyToMany
@Cascade({ CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.PERSIST})
- @JoinColumn(name = "author_id")
+ @JoinTable(joinColumns = { @JoinColumn(name = "author_id") })
private Set authors = new HashSet<>();
public void addAuthor(Author author) {
diff --git a/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/namedparameternotbound/NamedParameterNotBoundExceptionUnitTest.java b/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/namedparameternotbound/NamedParameterNotBoundExceptionUnitTest.java
index f16a89917d..82788ce562 100644
--- a/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/namedparameternotbound/NamedParameterNotBoundExceptionUnitTest.java
+++ b/persistence-modules/hibernate-exceptions/src/test/java/com/baeldung/hibernate/namedparameternotbound/NamedParameterNotBoundExceptionUnitTest.java
@@ -44,7 +44,7 @@ class NamedParameterNotBoundExceptionUnitTest {
query.list();
});
- String expectedMessage = "Named parameter not bound";
+ String expectedMessage = "No argument for named parameter";
String actualMessage = exception.getMessage();
assertTrue(actualMessage.contains(expectedMessage));
diff --git a/persistence-modules/hibernate-jpa/pom.xml b/persistence-modules/hibernate-jpa/pom.xml
index 603c749e95..b18ed85b41 100644
--- a/persistence-modules/hibernate-jpa/pom.xml
+++ b/persistence-modules/hibernate-jpa/pom.xml
@@ -15,7 +15,7 @@
- org.hibernate
+ org.hibernate.orm
hibernate-core
${hibernate.version}
@@ -84,6 +84,7 @@
8.2.0
+ 6.4.2.Final
2.6.0
3.0.4
2.1.214