diff --git a/persistence-modules/hibernate-annotations/pom.xml b/persistence-modules/hibernate-annotations/pom.xml
index 310b409a00..6417421fed 100644
--- a/persistence-modules/hibernate-annotations/pom.xml
+++ b/persistence-modules/hibernate-annotations/pom.xml
@@ -76,13 +76,18 @@
${org.springframework.version}
test
+
+ io.hypersistence
+ hypersistence-utils-hibernate-60
+ 3.3.1
+
- 5.0.2.RELEASE
- 1.10.6.RELEASE
- 5.6.7.Final
+ 6.0.6
+ 3.0.3
+ 6.1.7.Final
true
9.0.0.M26
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/creationupdatetimestamp/model/Book.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/creationupdatetimestamp/model/Book.java
index 0677b46690..0484c31ced 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/creationupdatetimestamp/model/Book.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/creationupdatetimestamp/model/Book.java
@@ -2,9 +2,9 @@ package com.baeldung.hibernate.creationupdatetimestamp.model;
import java.time.Instant;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/AddressType.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/AddressType.java
index c10c67df9a..f50d8fd7cc 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/AddressType.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/AddressType.java
@@ -1,11 +1,11 @@
package com.baeldung.hibernate.customtypes;
import org.hibernate.HibernateException;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
-import org.hibernate.type.IntegerType;
-import org.hibernate.type.StringType;
-import org.hibernate.type.Type;
+import org.hibernate.metamodel.spi.ValueAccess;
import org.hibernate.usertype.CompositeUserType;
+import org.hibernate.usertype.UserType;
import java.io.Serializable;
import java.sql.PreparedStatement;
@@ -14,74 +14,51 @@ import java.sql.SQLException;
import java.sql.Types;
import java.util.Objects;
-public class AddressType implements CompositeUserType {
+public class AddressType implements CompositeUserType
, UserType {
@Override
- public String[] getPropertyNames() {
- return new String[]{"addressLine1", "addressLine2",
- "city", "country", "zipcode"};
- }
-
- @Override
- public Type[] getPropertyTypes() {
- return new Type[]{StringType.INSTANCE, StringType.INSTANCE,
- StringType.INSTANCE, StringType.INSTANCE, IntegerType.INSTANCE};
- }
-
- @Override
- public Object getPropertyValue(Object component, int property) throws HibernateException {
-
- Address empAdd = (Address) component;
+ public Object getPropertyValue(Address component, int property) throws HibernateException {
switch (property) {
case 0:
- return empAdd.getAddressLine1();
+ return component.getAddressLine1();
case 1:
- return empAdd.getAddressLine2();
+ return component.getAddressLine2();
case 2:
- return empAdd.getCity();
+ return component.getCity();
case 3:
- return empAdd.getCountry();
+ return component.getCountry();
case 4:
- return Integer.valueOf(empAdd.getZipCode());
+ return component.getZipCode();
+ default:
+ throw new IllegalArgumentException(property +
+ " is an invalid property index for class type " +
+ component.getClass().getName());
}
-
- throw new IllegalArgumentException(property +
- " is an invalid property index for class type " +
- component.getClass().getName());
}
@Override
- public void setPropertyValue(Object component, int property, Object value) throws HibernateException {
-
- Address empAdd = (Address) component;
-
- switch (property) {
- case 0:
- empAdd.setAddressLine1((String) value);
- case 1:
- empAdd.setAddressLine2((String) value);
- case 2:
- empAdd.setCity((String) value);
- case 3:
- empAdd.setCountry((String) value);
- case 4:
- empAdd.setZipCode((Integer) value);
- }
-
- throw new IllegalArgumentException(property +
- " is an invalid property index for class type " +
- component.getClass().getName());
-
+ public Address instantiate(ValueAccess values, SessionFactoryImplementor sessionFactory) {
+ return null;
}
@Override
- public Class returnedClass() {
+ public Class> embeddable() {
return Address.class;
}
@Override
- public boolean equals(Object x, Object y) throws HibernateException {
+ public int getSqlType() {
+ return Types.VARCHAR;
+ }
+
+ @Override
+ public Class returnedClass() {
+ return Address.class;
+ }
+
+ @Override
+ public boolean equals(Address x, Address y) {
if (x == y)
return true;
@@ -92,57 +69,52 @@ public class AddressType implements CompositeUserType {
}
@Override
- public int hashCode(Object x) throws HibernateException {
+ public int hashCode(Address x) {
return x.hashCode();
}
@Override
- public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
-
+ public Address nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
Address empAdd = new Address();
- empAdd.setAddressLine1(rs.getString(names[0]));
+ empAdd.setAddressLine1(rs.getString(position));
if (rs.wasNull())
return null;
- empAdd.setAddressLine2(rs.getString(names[1]));
- empAdd.setCity(rs.getString(names[2]));
- empAdd.setCountry(rs.getString(names[3]));
- empAdd.setZipCode(rs.getInt(names[4]));
+ empAdd.setAddressLine2(rs.getString(position));
+ empAdd.setCity(rs.getString(position));
+ empAdd.setCountry(rs.getString(position));
+ empAdd.setZipCode(rs.getInt(position));
return empAdd;
}
@Override
- public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
-
+ public void nullSafeSet(PreparedStatement st, Address value, int index, SharedSessionContractImplementor session) throws SQLException {
if (Objects.isNull(value))
st.setNull(index, Types.VARCHAR);
else {
- Address empAdd = (Address) value;
- st.setString(index, empAdd.getAddressLine1());
- st.setString(index + 1, empAdd.getAddressLine2());
- st.setString(index + 2, empAdd.getCity());
- st.setString(index + 3, empAdd.getCountry());
- st.setInt(index + 4, empAdd.getZipCode());
+ st.setString(index, value.getAddressLine1());
+ st.setString(index + 1, value.getAddressLine2());
+ st.setString(index + 2, value.getCity());
+ st.setString(index + 3, value.getCountry());
+ st.setInt(index + 4, value.getZipCode());
}
}
@Override
- public Object deepCopy(Object value) throws HibernateException {
-
+ public Address deepCopy(Address value) {
if (Objects.isNull(value))
return null;
- Address oldEmpAdd = (Address) value;
Address newEmpAdd = new Address();
- newEmpAdd.setAddressLine1(oldEmpAdd.getAddressLine1());
- newEmpAdd.setAddressLine2(oldEmpAdd.getAddressLine2());
- newEmpAdd.setCity(oldEmpAdd.getCity());
- newEmpAdd.setCountry(oldEmpAdd.getCountry());
- newEmpAdd.setZipCode(oldEmpAdd.getZipCode());
+ newEmpAdd.setAddressLine1(value.getAddressLine1());
+ newEmpAdd.setAddressLine2(value.getAddressLine2());
+ newEmpAdd.setCity(value.getCity());
+ newEmpAdd.setCountry(value.getCountry());
+ newEmpAdd.setZipCode(value.getZipCode());
return newEmpAdd;
}
@@ -153,17 +125,27 @@ public class AddressType implements CompositeUserType {
}
@Override
- public Serializable disassemble(Object value, SharedSessionContractImplementor session) throws HibernateException {
+ public Serializable disassemble(Address value) {
return (Serializable) deepCopy(value);
}
@Override
- public Object assemble(Serializable cached, SharedSessionContractImplementor session, Object owner) throws HibernateException {
- return deepCopy(cached);
+ public Address assemble(Serializable cached, Object owner) {
+ return deepCopy((Address) cached);
}
@Override
- public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner) throws HibernateException {
- return original;
+ public Address replace(Address detached, Address managed, Object owner) {
+ return detached;
+ }
+
+ @Override
+ public boolean isInstance(Object object, SessionFactoryImplementor sessionFactory) {
+ return CompositeUserType.super.isInstance(object, sessionFactory);
+ }
+
+ @Override
+ public boolean isSameClass(Object object, SessionFactoryImplementor sessionFactory) {
+ return CompositeUserType.super.isSameClass(object, sessionFactory);
}
}
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/LocalDateStringJavaDescriptor.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/LocalDateStringJavaDescriptor.java
index 56be9e693f..8f1794b979 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/LocalDateStringJavaDescriptor.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/LocalDateStringJavaDescriptor.java
@@ -1,14 +1,14 @@
package com.baeldung.hibernate.customtypes;
-import org.hibernate.type.LocalDateType;
import org.hibernate.type.descriptor.WrapperOptions;
-import org.hibernate.type.descriptor.java.AbstractTypeDescriptor;
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
-import org.hibernate.type.descriptor.java.MutabilityPlan;
import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
-public class LocalDateStringJavaDescriptor extends AbstractTypeDescriptor {
+import io.hypersistence.utils.hibernate.type.array.internal.AbstractArrayTypeDescriptor;
+
+public class LocalDateStringJavaDescriptor extends AbstractArrayTypeDescriptor {
public static final LocalDateStringJavaDescriptor INSTANCE = new LocalDateStringJavaDescriptor();
@@ -18,12 +18,12 @@ public class LocalDateStringJavaDescriptor extends AbstractTypeDescriptor implements DiscriminatorType {
+public class LocalDateStringType extends AbstractSingleColumnStandardBasicType {
public static final LocalDateStringType INSTANCE = new LocalDateStringType();
public LocalDateStringType() {
- super(VarcharTypeDescriptor.INSTANCE, LocalDateStringJavaDescriptor.INSTANCE);
+ super(VarcharJdbcType.INSTANCE, LocalDateStringJavaDescriptor.INSTANCE);
}
@Override
@@ -21,14 +19,12 @@ public class LocalDateStringType extends AbstractSingleColumnStandardBasicType {
-public class PhoneNumberType implements UserType {
@Override
- public int[] sqlTypes() {
- return new int[]{Types.INTEGER, Types.INTEGER, Types.INTEGER};
+ public int getSqlType() {
+ return Types.INTEGER;
}
@Override
@@ -24,7 +23,7 @@ public class PhoneNumberType implements UserType {
}
@Override
- public boolean equals(Object x, Object y) throws HibernateException {
+ public boolean equals(PhoneNumber x, PhoneNumber y) {
if (x == y)
return true;
if (Objects.isNull(x) || Objects.isNull(y))
@@ -34,48 +33,42 @@ public class PhoneNumberType implements UserType {
}
@Override
- public int hashCode(Object x) throws HibernateException {
+ public int hashCode(PhoneNumber x) {
return x.hashCode();
}
@Override
- public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
- int countryCode = rs.getInt(names[0]);
+ public PhoneNumber nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
+ int countryCode = rs.getInt(position);
if (rs.wasNull())
return null;
- int cityCode = rs.getInt(names[1]);
- int number = rs.getInt(names[2]);
- PhoneNumber employeeNumber = new PhoneNumber(countryCode, cityCode, number);
+ int cityCode = rs.getInt(position);
+ int number = rs.getInt(position);
- return employeeNumber;
+ return new PhoneNumber(countryCode, cityCode, number);
}
@Override
- public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
-
+ public void nullSafeSet(PreparedStatement st, PhoneNumber value, int index, SharedSessionContractImplementor session) throws SQLException {
if (Objects.isNull(value)) {
st.setNull(index, Types.INTEGER);
st.setNull(index+1, Types.INTEGER);
st.setNull(index+2, Types.INTEGER);
} else {
- PhoneNumber employeeNumber = (PhoneNumber) value;
- st.setInt(index,employeeNumber.getCountryCode());
- st.setInt(index+1,employeeNumber.getCityCode());
- st.setInt(index+2,employeeNumber.getNumber());
+ st.setInt(index, value.getCountryCode());
+ st.setInt(index+1, value.getCityCode());
+ st.setInt(index+2, value.getNumber());
}
}
@Override
- public Object deepCopy(Object value) throws HibernateException {
+ public PhoneNumber deepCopy(PhoneNumber value) {
if (Objects.isNull(value))
return null;
- PhoneNumber empNumber = (PhoneNumber) value;
- PhoneNumber newEmpNumber = new PhoneNumber(empNumber.getCountryCode(),empNumber.getCityCode(),empNumber.getNumber());
-
- return newEmpNumber;
+ return new PhoneNumber(value.getCountryCode(), value.getCityCode(), value.getNumber());
}
@Override
@@ -84,17 +77,17 @@ public class PhoneNumberType implements UserType {
}
@Override
- public Serializable disassemble(Object value) throws HibernateException {
+ public Serializable disassemble(PhoneNumber value) {
return (Serializable) value;
}
@Override
- public Object assemble(Serializable cached, Object owner) throws HibernateException {
- return cached;
+ public PhoneNumber assemble(Serializable cached, Object owner) {
+ return (PhoneNumber) cached;
}
@Override
- public Object replace(Object original, Object target, Object owner) throws HibernateException {
- return original;
+ public PhoneNumber replace(PhoneNumber detached, PhoneNumber managed, Object owner) {
+ return detached;
}
}
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/SalaryType.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/SalaryType.java
index 266b85140b..69e34c1363 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/SalaryType.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/customtypes/SalaryType.java
@@ -1,12 +1,12 @@
package com.baeldung.hibernate.customtypes;
import org.hibernate.HibernateException;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
-import org.hibernate.type.LongType;
-import org.hibernate.type.StringType;
-import org.hibernate.type.Type;
+import org.hibernate.metamodel.spi.ValueAccess;
import org.hibernate.usertype.CompositeUserType;
import org.hibernate.usertype.DynamicParameterizedType;
+import org.hibernate.usertype.UserType;
import java.io.Serializable;
import java.sql.PreparedStatement;
@@ -16,65 +16,47 @@ import java.sql.Types;
import java.util.Objects;
import java.util.Properties;
-public class SalaryType implements CompositeUserType, DynamicParameterizedType {
+public class SalaryType implements UserType, CompositeUserType, DynamicParameterizedType {
private String localCurrency;
@Override
- public String[] getPropertyNames() {
- return new String[]{"amount", "currency"};
- }
-
- @Override
- public Type[] getPropertyTypes() {
- return new Type[]{LongType.INSTANCE, StringType.INSTANCE};
- }
-
- @Override
- public Object getPropertyValue(Object component, int property) throws HibernateException {
-
- Salary salary = (Salary) component;
+ public Object getPropertyValue(Salary component, int property) throws HibernateException {
switch (property) {
case 0:
- return salary.getAmount();
+ return component.getAmount();
case 1:
- return salary.getCurrency();
+ return component.getCurrency();
+ default:
+ throw new IllegalArgumentException(property +
+ " is an invalid property index for class type " +
+ component.getClass().getName());
}
-
- throw new IllegalArgumentException(property +
- " is an invalid property index for class type " +
- component.getClass().getName());
-
- }
-
-
- @Override
- public void setPropertyValue(Object component, int property, Object value) throws HibernateException {
-
- Salary salary = (Salary) component;
-
- switch (property) {
- case 0:
- salary.setAmount((Long) value);
- case 1:
- salary.setCurrency((String) value);
- }
-
- throw new IllegalArgumentException(property +
- " is an invalid property index for class type " +
- component.getClass().getName());
-
}
@Override
- public Class returnedClass() {
+ public Salary instantiate(ValueAccess values, SessionFactoryImplementor sessionFactory) {
+ return null;
+ }
+
+ @Override
+ public Class> embeddable() {
return Salary.class;
}
@Override
- public boolean equals(Object x, Object y) throws HibernateException {
+ public int getSqlType() {
+ return Types.BIGINT;
+ }
+ @Override
+ public Class returnedClass() {
+ return Salary.class;
+ }
+
+ @Override
+ public boolean equals(Salary x, Salary y) {
if (x == y)
return true;
@@ -82,54 +64,48 @@ public class SalaryType implements CompositeUserType, DynamicParameterizedType {
return false;
return x.equals(y);
-
}
@Override
- public int hashCode(Object x) throws HibernateException {
+ public int hashCode(Salary x) {
return x.hashCode();
}
@Override
- public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
-
+ public Salary nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
Salary salary = new Salary();
- salary.setAmount(rs.getLong(names[0]));
+ salary.setAmount(rs.getLong(position));
if (rs.wasNull())
return null;
- salary.setCurrency(rs.getString(names[1]));
+ salary.setCurrency(rs.getString(position));
return salary;
}
@Override
- public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
-
-
+ public void nullSafeSet(PreparedStatement st, Salary value, int index, SharedSessionContractImplementor session) throws SQLException {
if (Objects.isNull(value))
st.setNull(index, Types.BIGINT);
else {
- Salary salary = (Salary) value;
- st.setLong(index, SalaryCurrencyConvertor.convert(salary.getAmount(),
- salary.getCurrency(), localCurrency));
- st.setString(index + 1, salary.getCurrency());
+ st.setLong(index, SalaryCurrencyConvertor.convert(
+ value.getAmount(),
+ value.getCurrency(), localCurrency));
+ st.setString(index + 1, value.getCurrency());
}
}
@Override
- public Object deepCopy(Object value) throws HibernateException {
-
+ public Salary deepCopy(Salary value) {
if (Objects.isNull(value))
return null;
- Salary oldSal = (Salary) value;
Salary newSal = new Salary();
- newSal.setAmount(oldSal.getAmount());
- newSal.setCurrency(oldSal.getCurrency());
+ newSal.setAmount(value.getAmount());
+ newSal.setCurrency(value.getCurrency());
return newSal;
}
@@ -140,18 +116,18 @@ public class SalaryType implements CompositeUserType, DynamicParameterizedType {
}
@Override
- public Serializable disassemble(Object value, SharedSessionContractImplementor session) throws HibernateException {
+ public Serializable disassemble(Salary value) {
return (Serializable) deepCopy(value);
}
@Override
- public Object assemble(Serializable cached, SharedSessionContractImplementor session, Object owner) throws HibernateException {
- return deepCopy(cached);
+ public Salary assemble(Serializable cached, Object owner) {
+ return deepCopy((Salary) cached);
}
@Override
- public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner) throws HibernateException {
- return original;
+ public Salary replace(Salary detached, Salary managed, Object owner) {
+ return detached;
}
@Override
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/immutable/entities/Event.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/immutable/entities/Event.java
index ec88d629a6..f16aa68475 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/immutable/entities/Event.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/immutable/entities/Event.java
@@ -4,7 +4,7 @@ import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Immutable;
-import javax.persistence.*;
+import jakarta.persistence.*;
import java.util.Set;
@Entity
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/immutable/entities/EventGeneratedId.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/immutable/entities/EventGeneratedId.java
index 33af9313ae..6bf4006550 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/immutable/entities/EventGeneratedId.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/immutable/entities/EventGeneratedId.java
@@ -3,7 +3,7 @@ package com.baeldung.hibernate.immutable.entities;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Immutable;
-import javax.persistence.*;
+import jakarta.persistence.*;
@Entity
@Immutable
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/Email.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/Email.java
index df07c3cf69..096faf7984 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/Email.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/Email.java
@@ -1,12 +1,12 @@
package com.baeldung.hibernate.joincolumn;
-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 jakarta.persistence.Entity;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.ManyToOne;
@Entity
public class Email {
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/Office.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/Office.java
index 9940577761..3c6e5f4642 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/Office.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/Office.java
@@ -1,13 +1,13 @@
package com.baeldung.hibernate.joincolumn;
-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.JoinColumns;
-import javax.persistence.ManyToOne;
+import jakarta.persistence.Entity;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinColumns;
+import jakarta.persistence.ManyToOne;
@Entity
public class Office {
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/OfficeAddress.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/OfficeAddress.java
index cc723db6a2..d80a8be026 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/OfficeAddress.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/OfficeAddress.java
@@ -1,10 +1,10 @@
package com.baeldung.hibernate.joincolumn;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
@Entity
public class OfficeAddress {
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/OfficialEmployee.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/OfficialEmployee.java
index 49c63c7578..551b522700 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/OfficialEmployee.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/joincolumn/OfficialEmployee.java
@@ -1,12 +1,12 @@
package com.baeldung.hibernate.joincolumn;
import java.util.List;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
+import jakarta.persistence.Entity;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
+import jakarta.persistence.OneToMany;
@Entity
public class OfficialEmployee {
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/lazycollection/model/Branch.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/lazycollection/model/Branch.java
index de88647546..9957e2ce75 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/lazycollection/model/Branch.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/lazycollection/model/Branch.java
@@ -3,12 +3,12 @@ package com.baeldung.hibernate.lazycollection.model;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.OrderColumn;
-import javax.persistence.OneToMany;
-import javax.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
+import jakarta.persistence.OrderColumn;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.Entity;
import java.util.ArrayList;
import java.util.List;
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/lazycollection/model/Employee.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/lazycollection/model/Employee.java
index 831518a365..edf89696f5 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/lazycollection/model/Employee.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/lazycollection/model/Employee.java
@@ -1,11 +1,10 @@
package com.baeldung.hibernate.lazycollection.model;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.OrderColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.Entity;
@Entity
public class Employee {
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/config/HibernateAnnotationUtil.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/config/HibernateAnnotationUtil.java
index ef82c1c9ad..99410e1f76 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/config/HibernateAnnotationUtil.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/config/HibernateAnnotationUtil.java
@@ -43,8 +43,8 @@ public class HibernateAnnotationUtil {
return metadata.buildSessionFactory();
}
- private static Map dbSettings() {
- Map dbSettings = new HashMap<>();
+ private static Map dbSettings() {
+ Map dbSettings = new HashMap<>();
dbSettings.put(Environment.URL, "jdbc:h2:mem:spring_hibernate_one_to_many");
dbSettings.put(Environment.USER, "sa");
dbSettings.put(Environment.PASS, "");
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/Cart.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/Cart.java
index 53878af445..f07f3d3887 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/Cart.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/Cart.java
@@ -2,13 +2,13 @@ package com.baeldung.hibernate.oneToMany.model;
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.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.OneToMany;
+import jakarta.persistence.Table;
@Entity
@Table(name = "CART")
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/CartOIO.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/CartOIO.java
index 27b28a6753..f279cc4ea6 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/CartOIO.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/CartOIO.java
@@ -1,13 +1,13 @@
package com.baeldung.hibernate.oneToMany.model;
import java.util.Set;
-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.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 = "CARTOIO")
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/Item.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/Item.java
index a055682d0d..5babe9c545 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/Item.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/Item.java
@@ -1,13 +1,13 @@
package com.baeldung.hibernate.oneToMany.model;
-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.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 = "ITEMS")
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/ItemOIO.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/ItemOIO.java
index baaf57b106..78139da19e 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/ItemOIO.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/oneToMany/model/ItemOIO.java
@@ -1,12 +1,12 @@
package com.baeldung.hibernate.oneToMany.model;
-import javax.persistence.Entity;
-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.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 = "ITEMSOIO")
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/pojo/Phone.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/pojo/Phone.java
index d923bda5de..e173aa8b47 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/pojo/Phone.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/pojo/Phone.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;
import java.io.Serializable;
@Entity
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/Group.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/Group.java
index 04684eceac..2b17c9218d 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/Group.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/Group.java
@@ -3,10 +3,10 @@ package com.baeldung.hibernate.wherejointable;
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.ManyToMany;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.ManyToMany;
@Entity(name = "e_group")
public class Group {
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/User.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/User.java
index 3029aae640..a517de3cca 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/User.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/User.java
@@ -3,12 +3,12 @@ package com.baeldung.hibernate.wherejointable;
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.ManyToMany;
import org.hibernate.annotations.WhereJoinTable;
diff --git a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/UserGroupRelation.java b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/UserGroupRelation.java
index 00dd19699c..21a0a443c6 100644
--- a/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/UserGroupRelation.java
+++ b/persistence-modules/hibernate-annotations/src/main/java/com/baeldung/hibernate/wherejointable/UserGroupRelation.java
@@ -2,11 +2,11 @@ package com.baeldung.hibernate.wherejointable;
import java.io.Serializable;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.Id;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.Id;
@Entity(name = "r_user_group")
public class UserGroupRelation implements Serializable {
diff --git a/persistence-modules/hibernate-annotations/src/main/resources/META-INF/persistence.xml b/persistence-modules/hibernate-annotations/src/main/resources/META-INF/persistence.xml
index 474eeb7a44..2915125295 100644
--- a/persistence-modules/hibernate-annotations/src/main/resources/META-INF/persistence.xml
+++ b/persistence-modules/hibernate-annotations/src/main/resources/META-INF/persistence.xml
@@ -7,12 +7,12 @@
Hibernate EntityManager Demo
true
-
+
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/creationupdatetimestamp/HibernateCreationUpdateTimestampIntegrationTest.java b/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/creationupdatetimestamp/HibernateCreationUpdateTimestampIntegrationTest.java
index f309e9e22f..bab51dab72 100644
--- a/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/creationupdatetimestamp/HibernateCreationUpdateTimestampIntegrationTest.java
+++ b/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/creationupdatetimestamp/HibernateCreationUpdateTimestampIntegrationTest.java
@@ -1,5 +1,6 @@
package com.baeldung.hibernate.creationupdatetimestamp;
+import static org.hibernate.FlushMode.MANUAL;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -71,22 +72,22 @@ class HibernateCreationUpdateTimestampIntegrationTest {
}
@Test
- void whenCreatingEntity_ThenCreatedOnAndLastUpdatedOnAreNotEqual() {
+ void whenCreatingEntity_ThenCreatedOnAndLastUpdatedOnAreEqual() {
session = sessionFactory.openSession();
session.beginTransaction();
Book book = new Book();
session.save(book);
- session.getTransaction()
- .commit();
+ session.getTransaction().commit();
session.close();
- assertNotEquals(book.getCreatedOn(), book.getLastUpdatedOn());
+ assertEquals(book.getCreatedOn(), book.getLastUpdatedOn());
}
@Test
void whenUpdatingEntity_ThenLastUpdatedOnIsUpdatedAndCreatedOnStaysTheSame() {
session = sessionFactory.openSession();
+ session.setHibernateFlushMode(MANUAL);
session.beginTransaction();
Book book = new Book();
session.save(book);
@@ -96,8 +97,9 @@ class HibernateCreationUpdateTimestampIntegrationTest {
String newName = "newName";
book.setTitle(newName);
- session.getTransaction()
- .commit();
+ session.save(book);
+ session.flush();
+ session.getTransaction().commit();
session.close();
Instant createdOnAfterUpdate = book.getCreatedOn();
Instant lastUpdatedOnAfterUpdate = book.getLastUpdatedOn();
diff --git a/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/customtypes/HibernateCustomTypesIntegrationTest.java b/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/customtypes/HibernateCustomTypesIntegrationTest.java
index 460b65ee12..9da3a90034 100644
--- a/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/customtypes/HibernateCustomTypesIntegrationTest.java
+++ b/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/customtypes/HibernateCustomTypesIntegrationTest.java
@@ -6,10 +6,9 @@ import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Environment;
import org.hibernate.service.ServiceRegistry;
-import org.junit.Assert;
import org.junit.Test;
-import javax.persistence.TypedQuery;
+import jakarta.persistence.TypedQuery;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
@@ -76,7 +75,7 @@ public class HibernateCustomTypesIntegrationTest {
doInHibernate(this::sessionFactory, session -> {
session.save(e);
- TypedQuery query = session.createQuery("FROM OfficeEmployee OE WHERE OE.empAddress.zipcode = :pinCode", OfficeEmployee.class);
+ TypedQuery query = session.createQuery("FROM OfficeEmployee OE WHERE OE.empAddress.zipCode = :pinCode", OfficeEmployee.class);
query.setParameter("pinCode",100);
int size = query.getResultList().size();
@@ -100,8 +99,8 @@ public class HibernateCustomTypesIntegrationTest {
return metadata.buildSessionFactory();
}
- private static Map getProperties() {
- Map dbSettings = new HashMap<>();
+ private static Map getProperties() {
+ Map dbSettings = new HashMap<>();
dbSettings.put(Environment.URL, "jdbc:h2:mem:mydb1;DB_CLOSE_DELAY=-1");
dbSettings.put(Environment.USER, "sa");
dbSettings.put(Environment.PASS, "");
diff --git a/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/immutable/HibernateImmutableIntegrationTest.java b/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/immutable/HibernateImmutableIntegrationTest.java
index 270a235ef0..f038d2b16d 100644
--- a/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/immutable/HibernateImmutableIntegrationTest.java
+++ b/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/immutable/HibernateImmutableIntegrationTest.java
@@ -8,7 +8,7 @@ import org.hibernate.Session;
import org.junit.*;
import org.junit.rules.ExpectedException;
-import javax.persistence.PersistenceException;
+import jakarta.persistence.PersistenceException;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
diff --git a/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/joincolumn/JoinColumnIntegrationTest.java b/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/joincolumn/JoinColumnIntegrationTest.java
index 37125e8b15..04f0613811 100644
--- a/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/joincolumn/JoinColumnIntegrationTest.java
+++ b/persistence-modules/hibernate-annotations/src/test/java/com/baeldung/hibernate/joincolumn/JoinColumnIntegrationTest.java
@@ -78,8 +78,8 @@ public class JoinColumnIntegrationTest {
return metadata.buildSessionFactory();
}
- private static Map getProperties() {
- Map dbSettings = new HashMap<>();
+ private static Map getProperties() {
+ Map dbSettings = new HashMap<>();
dbSettings.put(Environment.URL, "jdbc:h2:mem:mydbJoinColumn;DB_CLOSE_DELAY=-1");
dbSettings.put(Environment.USER, "sa");
dbSettings.put(Environment.PASS, "");
diff --git a/persistence-modules/hibernate-enterprise/pom.xml b/persistence-modules/hibernate-enterprise/pom.xml
index 833f19c673..eaa7b0e765 100644
--- a/persistence-modules/hibernate-enterprise/pom.xml
+++ b/persistence-modules/hibernate-enterprise/pom.xml
@@ -78,10 +78,11 @@
- 5.3.7.Final
- 6.0.6
- 2.2.3
+ 6.1.7.Final
+ 8.0.32
+ 2.6.0
0.9
+ 1.14.2
\ No newline at end of file
diff --git a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/EntityWithNoId.java b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/EntityWithNoId.java
index 989fa1281a..8ef7487804 100644
--- a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/EntityWithNoId.java
+++ b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/EntityWithNoId.java
@@ -1,6 +1,6 @@
package com.baeldung.hibernate.exception;
-import javax.persistence.Entity;
+import jakarta.persistence.Entity;
@Entity
public class EntityWithNoId {
diff --git a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/Product.java b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/Product.java
index 0724ced56b..b7e80511e6 100644
--- a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/Product.java
+++ b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/Product.java
@@ -1,9 +1,9 @@
package com.baeldung.hibernate.exception;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
@Entity
@Table(name = "PRODUCT")
diff --git a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/ProductEntity.java b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/ProductEntity.java
index b9c5f5010d..a2dcec61e9 100644
--- a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/ProductEntity.java
+++ b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/ProductEntity.java
@@ -1,8 +1,8 @@
package com.baeldung.hibernate.exception;
-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 = "PRODUCT")
diff --git a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/ProductNotMapped.java b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/ProductNotMapped.java
new file mode 100644
index 0000000000..827ad15e5b
--- /dev/null
+++ b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/exception/ProductNotMapped.java
@@ -0,0 +1,32 @@
+package com.baeldung.hibernate.exception;
+
+public class ProductNotMapped {
+
+ private int id;
+ private String name;
+ private String description;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
diff --git a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/logging/Employee.java b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/logging/Employee.java
index 9dcf4058a7..bc50c11d81 100644
--- a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/logging/Employee.java
+++ b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/logging/Employee.java
@@ -1,9 +1,9 @@
package com.baeldung.hibernate.logging;
-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 Employee {
diff --git a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/pojo/PointEntity.java b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/pojo/PointEntity.java
index 736abde866..23b9a87eef 100644
--- a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/pojo/PointEntity.java
+++ b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/pojo/PointEntity.java
@@ -1,11 +1,11 @@
package com.baeldung.hibernate.pojo;
-import com.vividsolutions.jts.geom.Point;
+import org.locationtech.jts.geom.Point;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
@Entity
public class PointEntity {
diff --git a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/pojo/PolygonEntity.java b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/pojo/PolygonEntity.java
index 69208c8cd4..32cb146f23 100644
--- a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/pojo/PolygonEntity.java
+++ b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/pojo/PolygonEntity.java
@@ -1,10 +1,10 @@
package com.baeldung.hibernate.pojo;
-import com.vividsolutions.jts.geom.Polygon;
+import org.locationtech.jts.geom.Polygon;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
@Entity
public class PolygonEntity {
diff --git a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/pojo/Student.java b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/pojo/Student.java
index 9b26c117eb..263908a5fc 100644
--- a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/hibernate/pojo/Student.java
+++ b/persistence-modules/hibernate-enterprise/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-enterprise/src/main/java/com/baeldung/persistence/model/Person.java b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/persistence/model/Person.java
index 6a95a7acf5..3766639975 100644
--- a/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/persistence/model/Person.java
+++ b/persistence-modules/hibernate-enterprise/src/main/java/com/baeldung/persistence/model/Person.java
@@ -1,8 +1,8 @@
package com.baeldung.persistence.model;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
@Entity
public class Person {
diff --git a/persistence-modules/hibernate-enterprise/src/main/resources/META-INF/persistence.xml b/persistence-modules/hibernate-enterprise/src/main/resources/META-INF/persistence.xml
index 474eeb7a44..2915125295 100644
--- a/persistence-modules/hibernate-enterprise/src/main/resources/META-INF/persistence.xml
+++ b/persistence-modules/hibernate-enterprise/src/main/resources/META-INF/persistence.xml
@@ -7,12 +7,12 @@
Hibernate EntityManager Demo
true
-
+
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/HibernateSpatialIntegrationTest.java b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/HibernateSpatialIntegrationTest.java
index 74f752ab8c..e0f13582ab 100644
--- a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/HibernateSpatialIntegrationTest.java
+++ b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/HibernateSpatialIntegrationTest.java
@@ -9,23 +9,23 @@ import java.io.IOException;
import java.net.URL;
import java.util.Properties;
-import javax.persistence.Query;
+import jakarta.persistence.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.io.ParseException;
+import org.locationtech.jts.io.WKTReader;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.Point;
+import org.locationtech.jts.geom.Polygon;
+import org.locationtech.jts.util.GeometricShapeFactory;
import com.baeldung.hibernate.pojo.PointEntity;
import com.baeldung.hibernate.pojo.PolygonEntity;
-import com.vividsolutions.jts.geom.Coordinate;
-import com.vividsolutions.jts.geom.Geometry;
-import com.vividsolutions.jts.geom.Point;
-import com.vividsolutions.jts.geom.Polygon;
-import com.vividsolutions.jts.io.ParseException;
-import com.vividsolutions.jts.io.WKTReader;
-import com.vividsolutions.jts.util.GeometricShapeFactory;
import geodb.GeoDB;
@@ -39,7 +39,7 @@ public class HibernateSpatialIntegrationTest {
session = HibernateUtil.getSessionFactory("hibernate-spatial.properties")
.openSession();
transaction = session.beginTransaction();
- session.doWork(conn -> { GeoDB.InitGeoDB(conn); });
+ session.doWork(GeoDB::InitGeoDB);
}
@After
@@ -135,9 +135,7 @@ public class HibernateSpatialIntegrationTest {
private Geometry wktToGeometry(String wellKnownText) throws ParseException {
WKTReader fromText = new WKTReader();
- Geometry geom = null;
- geom = fromText.read(wellKnownText);
- return geom;
+ return fromText.read(wellKnownText);
}
private static Geometry createCircle(double x, double y, double radius) {
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 891352843d..37c21d1899 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
@@ -6,28 +6,25 @@ import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.util.List;
-import javax.persistence.OptimisticLockException;
-import javax.persistence.PersistenceException;
+import jakarta.persistence.OptimisticLockException;
+import jakarta.persistence.PersistenceException;
-import org.hibernate.AnnotationException;
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.TransactionException;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.DataException;
import org.hibernate.exception.SQLGrammarException;
-import org.hibernate.hql.internal.ast.QuerySyntaxException;
import org.hibernate.id.IdentifierGenerationException;
import org.hibernate.query.NativeQuery;
+import org.hibernate.query.sqm.UnknownEntityException;
import org.hibernate.tool.schema.spi.CommandAcceptanceException;
import org.hibernate.tool.schema.spi.SchemaManagementException;
import org.junit.Before;
@@ -63,12 +60,15 @@ public class HibernateExceptionUnitTest {
@Test
public void whenQueryExecutedWithUnmappedEntity_thenMappingException() {
- thrown.expectCause(isA(MappingException.class));
- thrown.expectMessage("Unknown entity: java.lang.String");
+ thrown.expect(isA(MappingException.class));
+ thrown.expectMessage("Unable to locate persister: com.baeldung.hibernate.exception.ProductNotMapped");
+
+ ProductNotMapped product = new ProductNotMapped();
+ product.setId(1);
+ product.setName("test");
Session session = sessionFactory.openSession();
- NativeQuery query = session.createNativeQuery("select name from PRODUCT", String.class);
- query.getResultList();
+ session.save(product);
}
@Test
@@ -82,8 +82,8 @@ public class HibernateExceptionUnitTest {
@Test
public void whenQueryExecutedWithInvalidClassName_thenQuerySyntaxException() {
- thrown.expectCause(isA(QuerySyntaxException.class));
- thrown.expectMessage("PRODUCT is not mapped [from PRODUCT]");
+ thrown.expectCause(isA(UnknownEntityException.class));
+ thrown.expectMessage("Could not resolve root entity 'PRODUCT");
Session session = sessionFactory.openSession();
List results = session.createQuery("from PRODUCT", Product.class)
@@ -92,8 +92,8 @@ public class HibernateExceptionUnitTest {
@Test
public void givenEntityWithoutId_whenSessionFactoryCreated_thenAnnotationException() {
- thrown.expect(AnnotationException.class);
- thrown.expectMessage("No identifier specified for entity");
+ thrown.expect(isA(HibernateException.class));
+ thrown.expectMessage("Entity 'com.baeldung.hibernate.exception.EntityWithNoId' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property)");
Configuration cfg = getConfiguration();
cfg.addAnnotatedClass(EntityWithNoId.class);
@@ -132,9 +132,8 @@ public class HibernateExceptionUnitTest {
@Test
public void givenMissingTable_whenEntitySaved_thenSQLGrammarException() {
- thrown.expect(isA(PersistenceException.class));
thrown.expectCause(isA(SQLGrammarException.class));
- thrown.expectMessage("SQLGrammarException: could not prepare statement");
+ thrown.expectMessage("could not prepare statement");
Configuration cfg = getConfiguration();
cfg.addAnnotatedClass(Product.class);
@@ -162,9 +161,8 @@ public class HibernateExceptionUnitTest {
@Test
public void givenMissingTable_whenQueryExecuted_thenSQLGrammarException() {
- thrown.expect(isA(PersistenceException.class));
thrown.expectCause(isA(SQLGrammarException.class));
- thrown.expectMessage("SQLGrammarException: could not prepare statement");
+ thrown.expectMessage("could not prepare statement");
Session session = sessionFactory.openSession();
NativeQuery query = session.createNativeQuery("select * from NON_EXISTING_TABLE", Product.class);
@@ -173,9 +171,8 @@ public class HibernateExceptionUnitTest {
@Test
public void whenDuplicateIdSaved_thenConstraintViolationException() {
- thrown.expect(isA(PersistenceException.class));
thrown.expectCause(isA(ConstraintViolationException.class));
- thrown.expectMessage("ConstraintViolationException: could not execute statement");
+ thrown.expectMessage("could not execute statement");
Session session = null;
Transaction transaction = null;
@@ -253,7 +250,7 @@ public class HibernateExceptionUnitTest {
@Test
public void givenQueryWithDataTypeMismatch_WhenQueryExecuted_thenDataException() {
thrown.expectCause(isA(DataException.class));
- thrown.expectMessage("org.hibernate.exception.DataException: could not prepare statement");
+ thrown.expectMessage("could not prepare statement");
Session session = sessionFactory.openSession();
NativeQuery query = session.createNativeQuery("select * from PRODUCT where id='wrongTypeId'", Product.class);
@@ -330,9 +327,8 @@ public class HibernateExceptionUnitTest {
@Test
public void whenUpdatingNonExistingObject_thenStaleStateException() {
- thrown.expect(isA(OptimisticLockException.class));
- thrown.expectMessage("Row was updated or deleted by another transaction");
- thrown.expectCause(isA(StaleObjectStateException.class));
+ 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=?");
Session session = null;
Transaction transaction = null;
@@ -356,7 +352,8 @@ public class HibernateExceptionUnitTest {
@Test
public void givenTxnMarkedRollbackOnly_whenCommitted_thenTransactionException() {
- thrown.expect(isA(TransactionException.class));
+ thrown.expect(isA(IllegalStateException.class));
+ thrown.expectMessage("Transaction already active");
Session session = null;
Transaction transaction = null;
@@ -368,6 +365,7 @@ public class HibernateExceptionUnitTest {
product1.setId(15);
product1.setName("Product1");
session.save(product1);
+ transaction = session.beginTransaction();
transaction.setRollbackOnly();
transaction.commit();
diff --git a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/Car.java b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/Car.java
index 1b6cee7e67..3e4895e5e6 100644
--- a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/Car.java
+++ b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/Car.java
@@ -2,9 +2,9 @@ package com.baeldung.hibernate.multitenancy;
import java.io.Serializable;
-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(name = "Car")
@Table(name = "Car")
diff --git a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/MultitenancyIntegrationTest.java b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/MultitenancyIntegrationTest.java
index fdc3f9fa81..2dc94172b1 100644
--- a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/MultitenancyIntegrationTest.java
+++ b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/MultitenancyIntegrationTest.java
@@ -79,9 +79,9 @@ public abstract class MultitenancyIntegrationTest {
private void createCarTable() {
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
- session.createSQLQuery("drop table Car if exists")
+ session.createNativeQuery("drop table Car if exists")
.executeUpdate();
- session.createSQLQuery("create table Car (brand varchar(255) primary key)")
+ session.createNativeQuery("create table Car (brand varchar(255) primary key)")
.executeUpdate();
tx.commit();
}
diff --git a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/database/DatabaseApproachMultitenancyIntegrationTest.java b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/database/DatabaseApproachMultitenancyIntegrationTest.java
index 92f477a646..904805f2ce 100644
--- a/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/database/DatabaseApproachMultitenancyIntegrationTest.java
+++ b/persistence-modules/hibernate-enterprise/src/test/java/com/baeldung/hibernate/multitenancy/database/DatabaseApproachMultitenancyIntegrationTest.java
@@ -1,7 +1,5 @@
package com.baeldung.hibernate.multitenancy.database;
-import java.io.IOException;
-
import org.junit.Test;
import com.baeldung.hibernate.multitenancy.MultitenancyIntegrationTest;
@@ -14,7 +12,7 @@ public class DatabaseApproachMultitenancyIntegrationTest extends MultitenancyInt
}
@Test
- public void givenDatabaseApproach_whenAddingEntries_thenOnlyAddedToConcreteDatabase() throws IOException {
+ public void givenDatabaseApproach_whenAddingEntries_thenOnlyAddedToConcreteDatabase() {
whenCurrentTenantIs(TenantIdNames.MYDB1);
whenAddCar("myCar");
thenCarFound("myCar");
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 eb1f410622..47abf6ff85 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
@@ -34,8 +34,13 @@ public class MapMultiTenantConnectionProvider extends AbstractMultiTenantConnect
private void initConnectionProviderForTenant(String tenantId) throws IOException {
Properties properties = new Properties();
properties.load(getClass().getResourceAsStream(String.format("/hibernate-database-%s.properties", tenantId)));
+ Map configProperties = new HashMap<>();
+ for (String key : properties.stringPropertyNames()) {
+ String value = properties.getProperty(key);
+ configProperties.put(key, value);
+ }
DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl();
- connectionProvider.configure(properties);
+ connectionProvider.configure(configProperties);
this.connectionProviderMap.put(tenantId, connectionProvider);
}
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 601eba651c..67b838fdf1 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
@@ -3,6 +3,8 @@ package com.baeldung.hibernate.multitenancy.schema;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
@@ -39,9 +41,14 @@ public class SchemaMultiTenantConnectionProvider extends AbstractMultiTenantConn
private ConnectionProvider initConnectionProvider() throws IOException {
Properties properties = new Properties();
properties.load(getClass().getResourceAsStream("/hibernate-schema-multitenancy.properties"));
+ Map configProperties = new HashMap<>();
+ for (String key : properties.stringPropertyNames()) {
+ String value = properties.getProperty(key);
+ configProperties.put(key, value);
+ }
DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl();
- connectionProvider.configure(properties);
+ connectionProvider.configure(configProperties);
return 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 8c571428b4..c3d2362339 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
@@ -7,7 +7,7 @@ import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
-import javax.persistence.PersistenceException;
+import jakarta.persistence.PersistenceException;
import org.hibernate.HibernateException;
import org.hibernate.Session;
diff --git a/persistence-modules/hibernate-enterprise/src/test/resources/hibernate-exception.properties b/persistence-modules/hibernate-enterprise/src/test/resources/hibernate-exception.properties
index e08a23166d..1e086f60d4 100644
--- a/persistence-modules/hibernate-enterprise/src/test/resources/hibernate-exception.properties
+++ b/persistence-modules/hibernate-enterprise/src/test/resources/hibernate-exception.properties
@@ -12,5 +12,3 @@ hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.acquire_increment=5
hibernate.c3p0.timeout=1800
-
-hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory
diff --git a/persistence-modules/hibernate-enterprise/src/test/resources/hibernate-spatial.properties b/persistence-modules/hibernate-enterprise/src/test/resources/hibernate-spatial.properties
index c16666cbf5..e156965ce7 100644
--- a/persistence-modules/hibernate-enterprise/src/test/resources/hibernate-spatial.properties
+++ b/persistence-modules/hibernate-enterprise/src/test/resources/hibernate-spatial.properties
@@ -4,7 +4,7 @@ hibernate.connection.username=sa
hibernate.connection.autocommit=true
jdbc.password=
-hibernate.dialect=org.hibernate.spatial.dialect.h2geodb.GeoDBDialect
+hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=create-drop
diff --git a/persistence-modules/hibernate-mapping/pom.xml b/persistence-modules/hibernate-mapping/pom.xml
index 506283a4fb..1e3dc8be5f 100644
--- a/persistence-modules/hibernate-mapping/pom.xml
+++ b/persistence-modules/hibernate-mapping/pom.xml
@@ -26,7 +26,7 @@
com.vladmihalcea
- hibernate-types-52
+ hibernate-types-60
${hibernate-types.version}
@@ -41,9 +41,9 @@
${hibernate-validator.version}
- org.glassfish
- javax.el
- ${org.glassfish.javax.el.version}
+ org.glassfish.expressly
+ expressly
+ 5.0.0
javax.money
@@ -66,16 +66,27 @@
commons-io
${commons-io.version}
+
+ com.fasterxml.jackson.module
+ jackson-module-jakarta-xmlbind-annotations
+ ${jackson-module-jakarta-xmlbind-annotation}
+
+
+ org.openjdk.nashorn
+ nashorn-core
+ 15.4
+
- 1.4.197
- 5.4.12.Final
- 2.10.4
- 6.0.16.Final
+ 2.1.214
+ 6.1.7.Final
+ 2.21.1
+ 8.0.0.Final
3.0.1-b11
- 1.0.3
- 1.3
+ 1.1
+ 1.4.2
+ 2.14.2
\ No newline at end of file
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java
index fbd8bd487b..cbd73832a4 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/HibernateUtil.java
@@ -21,6 +21,7 @@ import com.baeldung.hibernate.pojo.inheritance.Animal;
import com.baeldung.hibernate.pojo.inheritance.Bag;
import com.baeldung.hibernate.pojo.inheritance.Book;
import com.baeldung.hibernate.pojo.inheritance.Car;
+import com.baeldung.hibernate.pojo.inheritance.Laptop;
import com.baeldung.hibernate.pojo.inheritance.MyEmployee;
import com.baeldung.hibernate.pojo.inheritance.MyProduct;
import com.baeldung.hibernate.pojo.inheritance.Pen;
@@ -79,6 +80,7 @@ public class HibernateUtil {
metadataSources.addAnnotatedClass(com.baeldung.hibernate.entities.Department.class);
metadataSources.addAnnotatedClass(Animal.class);
metadataSources.addAnnotatedClass(Bag.class);
+ metadataSources.addAnnotatedClass(Laptop.class);
metadataSources.addAnnotatedClass(Book.class);
metadataSources.addAnnotatedClass(Car.class);
metadataSources.addAnnotatedClass(MyEmployee.class);
@@ -86,7 +88,6 @@ public class HibernateUtil {
metadataSources.addAnnotatedClass(Pen.class);
metadataSources.addAnnotatedClass(Pet.class);
metadataSources.addAnnotatedClass(Vehicle.class);
-
Metadata metadata = metadataSources.getMetadataBuilder()
.build();
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/CustomIntegerArrayType.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/CustomIntegerArrayType.java
index 1155a59a57..5d3e22bf05 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/CustomIntegerArrayType.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/CustomIntegerArrayType.java
@@ -7,60 +7,57 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Arrays;
-import java.util.Objects;
-import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.usertype.UserType;
-public class CustomIntegerArrayType implements UserType {
+public class CustomIntegerArrayType implements UserType {
@Override
- public int[] sqlTypes() {
- return new int[]{Types.ARRAY};
+ public int getSqlType() {
+ return Types.ARRAY;
}
@Override
- public Class returnedClass() {
+ public Class returnedClass() {
return Integer[].class;
}
@Override
- public boolean equals(Object x, Object y) throws HibernateException {
+ public boolean equals(Integer[] x, Integer[] y) {
if (x instanceof Integer[] && y instanceof Integer[]) {
- return Arrays.deepEquals((Integer[])x, (Integer[])y);
+ return Arrays.deepEquals(x, y);
} else {
return false;
}
}
@Override
- public int hashCode(Object x) throws HibernateException {
- return Arrays.hashCode((Integer[])x);
+ public int hashCode(Integer[] x) {
+ return Arrays.hashCode(x);
}
@Override
- public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
- throws HibernateException, SQLException {
- Array array = rs.getArray(names[0]);
- return array != null ? array.getArray() : null;
+ public Integer[] nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
+ Array array = rs.getArray(position);
+ return array != null ? (Integer[]) array.getArray() : null;
}
@Override
- public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session)
- throws HibernateException, SQLException {
- if (value != null && st != null) {
- Array array = session.connection().createArrayOf("int", (Integer[])value);
- st.setArray(index, array);
- } else {
- st.setNull(index, sqlTypes()[0]);
+ public void nullSafeSet(PreparedStatement st, Integer[] value, int index, SharedSessionContractImplementor session) throws SQLException {
+ if (st != null) {
+ if (value != null) {
+ Array array = session.getJdbcConnectionAccess().obtainConnection().createArrayOf("int", value);
+ st.setArray(index, array);
+ } else {
+ st.setNull(index, Types.ARRAY);
+ }
}
}
@Override
- public Object deepCopy(Object value) throws HibernateException {
- Integer[] arr = (Integer[]) value;
- return arr != null ? Arrays.copyOf(arr, arr.length) : null;
+ public Integer[] deepCopy(Integer[] value) {
+ return value != null ? Arrays.copyOf(value, value.length) : null;
}
@Override
@@ -69,18 +66,18 @@ public class CustomIntegerArrayType implements UserType {
}
@Override
- public Serializable disassemble(Object value) throws HibernateException {
- return (Serializable) value;
+ public Serializable disassemble(Integer[] value) {
+ return value;
}
@Override
- public Object assemble(Serializable cached, Object owner) throws HibernateException {
- return cached;
+ public Integer[] assemble(Serializable cached, Object owner) {
+ return (Integer[]) cached;
}
@Override
- public Object replace(Object original, Object target, Object owner) throws HibernateException {
- return original;
+ public Integer[] replace(Integer[] detached, Integer[] managed, Object owner) {
+ return detached;
}
}
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/CustomStringArrayType.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/CustomStringArrayType.java
index ce50196513..31a082fb05 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/CustomStringArrayType.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/CustomStringArrayType.java
@@ -7,60 +7,57 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Arrays;
-import java.util.Objects;
-import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.usertype.UserType;
-public class CustomStringArrayType implements UserType {
+public class CustomStringArrayType implements UserType {
@Override
- public int[] sqlTypes() {
- return new int[]{Types.ARRAY};
+ public int getSqlType() {
+ return Types.ARRAY;
}
@Override
- public Class returnedClass() {
+ public Class returnedClass() {
return String[].class;
}
@Override
- public boolean equals(Object x, Object y) throws HibernateException {
+ public boolean equals(String[] x, String[] y) {
if (x instanceof String[] && y instanceof String[]) {
- return Arrays.deepEquals((String[])x, (String[])y);
+ return Arrays.deepEquals(x, y);
} else {
return false;
}
}
@Override
- public int hashCode(Object x) throws HibernateException {
- return Arrays.hashCode((String[])x);
+ public int hashCode(String[] x) {
+ return Arrays.hashCode(x);
}
@Override
- public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
- throws HibernateException, SQLException {
- Array array = rs.getArray(names[0]);
- return array != null ? array.getArray() : null;
+ public String[] nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
+ Array array = rs.getArray(position);
+ return array != null ? (String[]) array.getArray() : null;
}
@Override
- public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session)
- throws HibernateException, SQLException {
- if (value != null && st != null) {
- Array array = session.connection().createArrayOf("text", (String[])value);
- st.setArray(index, array);
- } else {
- st.setNull(index, sqlTypes()[0]);
+ public void nullSafeSet(PreparedStatement st, String[] value, int index, SharedSessionContractImplementor session) throws SQLException {
+ if (st != null) {
+ if (value != null) {
+ Array array = session.getJdbcConnectionAccess().obtainConnection().createArrayOf("text", value);
+ st.setArray(index, array);
+ } else {
+ st.setNull(index, Types.ARRAY);
+ }
}
}
@Override
- public Object deepCopy(Object value) throws HibernateException {
- String[] arr = (String[]) value;
- return arr != null ? Arrays.copyOf(arr, arr.length) : null;
+ public String[] deepCopy(String[] value) {
+ return value != null ? Arrays.copyOf(value, value.length) : null;
}
@Override
@@ -69,18 +66,18 @@ public class CustomStringArrayType implements UserType {
}
@Override
- public Serializable disassemble(Object value) throws HibernateException {
- return (Serializable) value;
+ public Serializable disassemble(String[] value) {
+ return value;
}
@Override
- public Object assemble(Serializable cached, Object owner) throws HibernateException {
- return cached;
+ public String[] assemble(Serializable cached, Object owner) {
+ return (String[]) cached;
}
@Override
- public Object replace(Object original, Object target, Object owner) throws HibernateException {
- return original;
+ public String[] replace(String[] detached, String[] managed, Object owner) {
+ return detached;
}
}
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/User.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/User.java
index 018bedc349..81f2ee89f7 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/User.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/arraymapping/User.java
@@ -1,21 +1,13 @@
package com.baeldung.hibernate.arraymapping;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
import org.hibernate.annotations.Type;
import com.vladmihalcea.hibernate.type.array.StringArrayType;
-import org.hibernate.annotations.*;
-
-@TypeDefs({
- @TypeDef(
- name = "string-array",
- typeClass = StringArrayType.class
- )
-})
@Entity
public class User {
@@ -25,14 +17,14 @@ public class User {
private String name;
@Column(columnDefinition = "text[]")
- @Type(type = "com.baeldung.hibernate.arraymapping.CustomStringArrayType")
+ @Type(value = com.baeldung.hibernate.arraymapping.CustomStringArrayType.class)
private String[] roles;
@Column(columnDefinition = "int[]")
- @Type(type = "com.baeldung.hibernate.arraymapping.CustomIntegerArrayType")
+ @Type(value = com.baeldung.hibernate.arraymapping.CustomIntegerArrayType.class)
private Integer[] locations;
- @Type(type = "string-array")
+ @Type(StringArrayType.class)
@Column(
name = "phone_numbers",
columnDefinition = "text[]"
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/basicannotation/Course.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/basicannotation/Course.java
index e816fb0176..ca77888f9b 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/basicannotation/Course.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/basicannotation/Course.java
@@ -1,10 +1,9 @@
package com.baeldung.hibernate.basicannotation;
-import javax.persistence.Basic;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
+import jakarta.persistence.Basic;
+import jakarta.persistence.Entity;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.Id;
@Entity
public class Course {
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/entities/Department.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/entities/Department.java
index ff94f4f849..39e69a2b1c 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/entities/Department.java
+++ b/persistence-modules/hibernate-mapping/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-mapping/src/main/java/com/baeldung/hibernate/entities/DeptEmployee.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/entities/DeptEmployee.java
index 6510e70650..3c4f542ce7 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/entities/DeptEmployee.java
+++ b/persistence-modules/hibernate-mapping/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 = :designation"),
@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-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Customer.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Customer.java
index 5589601da8..b8937c6692 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Customer.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Customer.java
@@ -3,10 +3,10 @@ package com.baeldung.hibernate.fetchMode;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.OneToMany;
import java.util.HashSet;
import java.util.Set;
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Order.java
index aa9c517321..5be65bac0d 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Order.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/fetchMode/Order.java
@@ -1,6 +1,6 @@
package com.baeldung.hibernate.fetchMode;
-import javax.persistence.*;
+import jakarta.persistence.*;
@Entity
public class Order {
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/lob/model/User.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/lob/model/User.java
index 21f725b388..3c3b748990 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/lob/model/User.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/lob/model/User.java
@@ -1,13 +1,13 @@
package com.baeldung.hibernate.lob.model;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.Table;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Lob;
+import jakarta.persistence.Table;
@Entity
-@Table(name="user")
+@Table(name="users")
public class User {
@Id
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Item.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Item.java
index 385ffe93ea..ff8115f5d9 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Item.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Item.java
@@ -2,15 +2,15 @@ package com.baeldung.hibernate.persistmaps.mapkey;
import com.baeldung.hibernate.persistmaps.ItemType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+import jakarta.persistence.Temporal;
+import jakarta.persistence.TemporalType;
import java.util.Date;
import java.util.Objects;
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Order.java
index 8409cacd6b..e42ceda5de 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Order.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/Order.java
@@ -1,15 +1,15 @@
package com.baeldung.hibernate.persistmaps.mapkey;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.MapKey;
-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.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.MapKey;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.Table;
import java.util.Map;
@Entity
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/User.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/User.java
index b2ee7e85fe..0a9694f43c 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/User.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkey/User.java
@@ -1,16 +1,15 @@
package com.baeldung.hibernate.persistmaps.mapkey;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.validation.constraints.Size;
-import javax.money.MonetaryAmount;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+import jakarta.validation.constraints.Size;
import org.hibernate.validator.constraints.Length;
-import org.hibernate.validator.constraints.CreditCardNumber;
-import org.hibernate.validator.constraints.Currency;
@Entity
+@Table(name="users2")
public class User {
@Id
@Column(length = 3)
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeycolumn/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeycolumn/Order.java
index fa092060da..3d24c743d7 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeycolumn/Order.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeycolumn/Order.java
@@ -1,14 +1,14 @@
package com.baeldung.hibernate.persistmaps.mapkeycolumn;
-import javax.persistence.CollectionTable;
-import javax.persistence.Column;
-import javax.persistence.ElementCollection;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.MapKeyColumn;
-import javax.persistence.Table;
+import jakarta.persistence.CollectionTable;
+import jakarta.persistence.Column;
+import jakarta.persistence.ElementCollection;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.MapKeyColumn;
+import jakarta.persistence.Table;
import java.util.Map;
@Entity
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyenumerated/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyenumerated/Order.java
index e1f62599b8..19622ea01d 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyenumerated/Order.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyenumerated/Order.java
@@ -3,17 +3,17 @@ package com.baeldung.hibernate.persistmaps.mapkeyenumerated;
import com.baeldung.hibernate.persistmaps.ItemType;
import com.baeldung.hibernate.persistmaps.mapkey.Item;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.MapKeyEnumerated;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
+import jakarta.persistence.CascadeType;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.MapKeyEnumerated;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.Table;
import java.util.Map;
@Entity
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Item.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Item.java
index 97bbd5b539..9ed58305da 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Item.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Item.java
@@ -2,18 +2,18 @@ package com.baeldung.hibernate.persistmaps.mapkeyjoincolumn;
import com.baeldung.hibernate.persistmaps.ItemType;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
+import jakarta.persistence.CascadeType;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.Table;
+import jakarta.persistence.Temporal;
+import jakarta.persistence.TemporalType;
import java.util.Date;
import java.util.Objects;
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Order.java
index d680d84501..9d20237860 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Order.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Order.java
@@ -1,15 +1,15 @@
package com.baeldung.hibernate.persistmaps.mapkeyjoincolumn;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.MapKeyJoinColumn;
-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.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.MapKeyJoinColumn;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.Table;
import java.util.Map;
@Entity
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Seller.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Seller.java
index 15b08e9fe6..ca06db241e 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Seller.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeyjoincolumn/Seller.java
@@ -1,10 +1,10 @@
package com.baeldung.hibernate.persistmaps.mapkeyjoincolumn;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
import java.util.Objects;
@Entity
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeytemporal/Order.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeytemporal/Order.java
index be602c1e9f..920d693d16 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeytemporal/Order.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/persistmaps/mapkeytemporal/Order.java
@@ -2,17 +2,17 @@ package com.baeldung.hibernate.persistmaps.mapkeytemporal;
import com.baeldung.hibernate.persistmaps.mapkey.Item;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.MapKeyTemporal;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.persistence.TemporalType;
+import jakarta.persistence.CascadeType;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.MapKeyTemporal;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.Table;
+import jakarta.persistence.TemporalType;
import java.util.Date;
import java.util.Map;
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/Employee.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/Employee.java
index e9732b2b67..7d8a254eec 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/Employee.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/Employee.java
@@ -2,15 +2,15 @@ package com.baeldung.hibernate.pojo;
import org.hibernate.annotations.*;
-import javax.persistence.Entity;
-import javax.persistence.*;
+import jakarta.persistence.Entity;
+import jakarta.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@Entity
@Where(clause = "deleted = false")
-@FilterDef(name = "incomeLevelFilter", parameters = @ParamDef(name = "incomeLimit", type = "int"))
+@FilterDef(name = "incomeLevelFilter", parameters = @ParamDef(name = "incomeLimit", type = Integer.class))
@Filter(name = "incomeLevelFilter", condition = "grossIncome > :incomeLimit")
public class Employee implements Serializable {
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/EntityDescription.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/EntityDescription.java
index 131bb73a80..29befd80f2 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/EntityDescription.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/EntityDescription.java
@@ -1,8 +1,11 @@
package com.baeldung.hibernate.pojo;
import org.hibernate.annotations.Any;
+import org.hibernate.annotations.AnyDiscriminator;
+import org.hibernate.annotations.AnyDiscriminatorValue;
+import org.hibernate.annotations.AnyKeyJavaClass;
-import javax.persistence.*;
+import jakarta.persistence.*;
import java.io.Serializable;
@Entity
@@ -14,10 +17,12 @@ public class EntityDescription implements Serializable {
private String description;
- @Any(
- metaDef = "EntityDescriptionMetaDef",
- metaColumn = @Column(name = "entity_type")
- )
+ @Any
+ @AnyDiscriminator(DiscriminatorType.STRING)
+ @AnyDiscriminatorValue(discriminator = "S", entity = Employee.class)
+ @AnyDiscriminatorValue(discriminator = "I", entity = Phone.class)
+ @AnyKeyJavaClass(Integer.class)
+ @Column(name = "entity_type")
@JoinColumn(name = "entity_id")
private Serializable entity;
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/Phone.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/Phone.java
index d923bda5de..e173aa8b47 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/Phone.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/Phone.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;
import java.io.Serializable;
@Entity
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/TemporalValues.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/TemporalValues.java
index f3fe095cae..0c022884eb 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/TemporalValues.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/TemporalValues.java
@@ -1,7 +1,6 @@
package com.baeldung.hibernate.pojo;
-import javax.persistence.*;
-import java.io.Serializable;
+import jakarta.persistence.*;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
@@ -9,7 +8,7 @@ import java.time.*;
import java.util.Calendar;
@Entity
-public class TemporalValues implements Serializable {
+public class TemporalValues {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@@ -48,7 +47,7 @@ public class TemporalValues implements Serializable {
private java.time.LocalDate localDate;
@Basic
- private java.time.LocalTime localTime;
+ private java.time.LocalTime localTimeField;
@Basic
private java.time.OffsetTime offsetTime;
@@ -146,11 +145,11 @@ public class TemporalValues implements Serializable {
}
public LocalTime getLocalTime() {
- return localTime;
+ return localTimeField;
}
public void setLocalTime(LocalTime localTime) {
- this.localTime = localTime;
+ this.localTimeField = localTime;
}
public OffsetTime getOffsetTime() {
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Animal.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Animal.java
index 6fe7f915fc..c44a542b60 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Animal.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Animal.java
@@ -1,9 +1,9 @@
package com.baeldung.hibernate.pojo.inheritance;
-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-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Bag.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Bag.java
index fa6e1b4bef..707e387866 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Bag.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Bag.java
@@ -1,7 +1,7 @@
package com.baeldung.hibernate.pojo.inheritance;
-import javax.persistence.Entity;
-import javax.persistence.Id;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
import org.hibernate.annotations.Polymorphism;
import org.hibernate.annotations.PolymorphismType;
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Book.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Book.java
index 36ca8dd77c..286a30cc14 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Book.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Book.java
@@ -1,7 +1,7 @@
package com.baeldung.hibernate.pojo.inheritance;
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
+import jakarta.persistence.DiscriminatorValue;
+import jakarta.persistence.Entity;
@Entity
@DiscriminatorValue("1")
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Car.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Car.java
index 49d1f7749a..987e299625 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Car.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Car.java
@@ -1,6 +1,6 @@
package com.baeldung.hibernate.pojo.inheritance;
-import javax.persistence.Entity;
+import jakarta.persistence.Entity;
@Entity
public class Car extends Vehicle {
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Laptop.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Laptop.java
new file mode 100644
index 0000000000..cced365d78
--- /dev/null
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Laptop.java
@@ -0,0 +1,39 @@
+package com.baeldung.hibernate.pojo.inheritance;
+
+import org.hibernate.annotations.Polymorphism;
+import org.hibernate.annotations.PolymorphismType;
+
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+
+@Entity
+@Polymorphism(type = PolymorphismType.IMPLICIT)
+public class Laptop implements Item {
+
+ @Id
+ private Long id;
+
+ private String type;
+
+ public Laptop(Long id, String type) {
+ this.id = id;
+ this.type = type;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+}
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/MyEmployee.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/MyEmployee.java
index 9a6bce16cf..96958c6e28 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/MyEmployee.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/MyEmployee.java
@@ -1,6 +1,6 @@
package com.baeldung.hibernate.pojo.inheritance;
-import javax.persistence.Entity;
+import jakarta.persistence.Entity;
@Entity
public class MyEmployee extends Person {
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/MyProduct.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/MyProduct.java
index 13f04d8904..62214fc16e 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/MyProduct.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/MyProduct.java
@@ -1,13 +1,11 @@
package com.baeldung.hibernate.pojo.inheritance;
-import javax.persistence.DiscriminatorColumn;
-import javax.persistence.DiscriminatorType;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-
-import org.hibernate.annotations.DiscriminatorFormula;
+import jakarta.persistence.DiscriminatorColumn;
+import jakarta.persistence.DiscriminatorType;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Inheritance;
+import jakarta.persistence.InheritanceType;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Pen.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Pen.java
index 32b77e52af..2382cab405 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Pen.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Pen.java
@@ -1,7 +1,7 @@
package com.baeldung.hibernate.pojo.inheritance;
-import javax.persistence.DiscriminatorValue;
-import javax.persistence.Entity;
+import jakarta.persistence.DiscriminatorValue;
+import jakarta.persistence.Entity;
@Entity
@DiscriminatorValue("2")
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Person.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Person.java
index 99084b88af..9bf8ac254c 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Person.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Person.java
@@ -1,7 +1,7 @@
package com.baeldung.hibernate.pojo.inheritance;
-import javax.persistence.Id;
-import javax.persistence.MappedSuperclass;
+import jakarta.persistence.Id;
+import jakarta.persistence.MappedSuperclass;
@MappedSuperclass
public class Person {
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Pet.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Pet.java
index 870b3cd684..b359eb3a21 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Pet.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Pet.java
@@ -1,7 +1,7 @@
package com.baeldung.hibernate.pojo.inheritance;
-import javax.persistence.Entity;
-import javax.persistence.PrimaryKeyJoinColumn;
+import jakarta.persistence.Entity;
+import jakarta.persistence.PrimaryKeyJoinColumn;
@Entity
@PrimaryKeyJoinColumn(name = "petId")
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Vehicle.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Vehicle.java
index b2a920573e..9bdde8c33b 100644
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Vehicle.java
+++ b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/inheritance/Vehicle.java
@@ -1,9 +1,9 @@
package com.baeldung.hibernate.pojo.inheritance;
-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.TABLE_PER_CLASS)
diff --git a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/package-info.java b/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/package-info.java
deleted file mode 100644
index 992cda7c1d..0000000000
--- a/persistence-modules/hibernate-mapping/src/main/java/com/baeldung/hibernate/pojo/package-info.java
+++ /dev/null
@@ -1,9 +0,0 @@
-@AnyMetaDef(name = "EntityDescriptionMetaDef", metaType = "string", idType = "int",
- metaValues = {
- @MetaValue(value = "Employee", targetEntity = Employee.class),
- @MetaValue(value = "Phone", targetEntity = Phone.class)
- })
-package com.baeldung.hibernate.pojo;
-
-import org.hibernate.annotations.AnyMetaDef;
-import org.hibernate.annotations.MetaValue;
\ No newline at end of file
diff --git a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/DynamicMappingIntegrationTest.java b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/DynamicMappingIntegrationTest.java
index 7a112200b5..833c5cc3ff 100644
--- a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/DynamicMappingIntegrationTest.java
+++ b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/DynamicMappingIntegrationTest.java
@@ -119,8 +119,8 @@ public class DynamicMappingIntegrationTest {
assertThat(employees).hasSize(2);
- Employee employee = session.get(Employee.class, 1);
- assertThat(employee.getGrossIncome()).isEqualTo(10_000);
+ Employee employee = session.get(Employee.class, 2);
+ assertThat(employee.getGrossIncome()).isEqualTo(12_000);
session.disableFilter("incomeLevelFilter");
employees = session.createQuery("from Employee").getResultList();
diff --git a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/InheritanceMappingIntegrationTest.java b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/InheritanceMappingIntegrationTest.java
index 0f35dbb8af..7f4cac141c 100644
--- a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/InheritanceMappingIntegrationTest.java
+++ b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/InheritanceMappingIntegrationTest.java
@@ -13,6 +13,7 @@ import org.junit.Test;
import com.baeldung.hibernate.pojo.inheritance.Bag;
import com.baeldung.hibernate.pojo.inheritance.Book;
import com.baeldung.hibernate.pojo.inheritance.Car;
+import com.baeldung.hibernate.pojo.inheritance.Laptop;
import com.baeldung.hibernate.pojo.inheritance.MyEmployee;
import com.baeldung.hibernate.pojo.inheritance.Pen;
import com.baeldung.hibernate.pojo.inheritance.Pet;
@@ -81,9 +82,12 @@ public class InheritanceMappingIntegrationTest {
public void givenSubclasses_whenQueryNonMappedInterface_thenOk() {
Bag bag = new Bag(1, "large");
session.save(bag);
+
+ Laptop laptop = new Laptop(1L, "Dell");
+ session.save(laptop);
assertThat(session.createQuery("from com.baeldung.hibernate.pojo.inheritance.Item")
.getResultList()
- .size()).isEqualTo(0);
+ .size()).isEqualTo(1);
}
}
diff --git a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/basicannotation/BasicAnnotationIntegrationTest.java b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/basicannotation/BasicAnnotationIntegrationTest.java
index 930bea60c5..6a9a4f095b 100644
--- a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/basicannotation/BasicAnnotationIntegrationTest.java
+++ b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/basicannotation/BasicAnnotationIntegrationTest.java
@@ -2,7 +2,7 @@ package com.baeldung.hibernate.basicannotation;
import java.io.IOException;
-import javax.persistence.PersistenceException;
+import jakarta.persistence.PersistenceException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
diff --git a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/validation/UserAdditionalValidationUnitTest.java b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/validation/UserAdditionalValidationUnitTest.java
index 0f2a0403e9..17212173ec 100644
--- a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/validation/UserAdditionalValidationUnitTest.java
+++ b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/validation/UserAdditionalValidationUnitTest.java
@@ -7,13 +7,12 @@ import java.math.BigDecimal;
import java.time.Duration;
import java.util.Set;
-import javax.money.CurrencyContextBuilder;
import javax.money.Monetary;
import javax.money.MonetaryAmount;
-import javax.validation.ConstraintViolation;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
+import jakarta.validation.ConstraintViolation;
+import jakarta.validation.Validation;
+import jakarta.validation.Validator;
+import jakarta.validation.ValidatorFactory;
import org.hibernate.validator.constraints.CodePointLength;
import org.hibernate.validator.constraints.CreditCardNumber;
@@ -21,12 +20,10 @@ import org.hibernate.validator.constraints.Currency;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.LuhnCheck;
import org.hibernate.validator.constraints.Range;
-import org.hibernate.validator.constraints.SafeHtml;
import org.hibernate.validator.constraints.ScriptAssert;
import org.hibernate.validator.constraints.URL;
import org.hibernate.validator.constraints.time.DurationMax;
import org.hibernate.validator.constraints.time.DurationMin;
-import org.javamoney.moneta.CurrencyUnitBuilder;
import org.javamoney.moneta.Money;
import org.junit.BeforeClass;
import org.junit.Test;
diff --git a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/validation/UserValidationUnitTest.java b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/validation/UserValidationUnitTest.java
index e39f324856..495ad657be 100644
--- a/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/validation/UserValidationUnitTest.java
+++ b/persistence-modules/hibernate-mapping/src/test/java/com/baeldung/hibernate/validation/UserValidationUnitTest.java
@@ -2,11 +2,11 @@ package com.baeldung.hibernate.validation;
import static org.junit.Assert.assertEquals;
import java.util.Set;
-import javax.persistence.PersistenceException;
-import javax.validation.ConstraintViolation;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
+import jakarta.persistence.PersistenceException;
+import jakarta.validation.ConstraintViolation;
+import jakarta.validation.Validation;
+import jakarta.validation.Validator;
+import jakarta.validation.ValidatorFactory;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.junit.Before;
diff --git a/persistence-modules/hibernate-queries/pom.xml b/persistence-modules/hibernate-queries/pom.xml
index 68a46b82b1..bb60c7b83a 100644
--- a/persistence-modules/hibernate-queries/pom.xml
+++ b/persistence-modules/hibernate-queries/pom.xml
@@ -85,15 +85,21 @@
${testcontainers.mysql.version}
test
+
+ io.hypersistence
+ hypersistence-utils-hibernate-60
+ 3.3.1
+
- 5.0.2.RELEASE
- 1.10.6.RELEASE
+ 6.0.6
+ 3.0.3
9.0.0.M26
- 6.0.6
- 2.2.3
+ 8.0.32
+ 2.6.0
2.1.214
+ 6.1.7.Final
1.17.6
diff --git a/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/model/Employee.java b/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/model/Employee.java
index 8771e02e0b..9041c6727c 100644
--- a/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/model/Employee.java
+++ b/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/model/Employee.java
@@ -1,7 +1,7 @@
package com.baeldung.hibernate.criteria.model;
import java.io.Serializable;
-import javax.persistence.Entity;
+import jakarta.persistence.Entity;
@org.hibernate.annotations.NamedQueries({
@org.hibernate.annotations.NamedQuery(name = "Employee_findByEmployeeId", query = "from Employee where id = :employeeId"),
diff --git a/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/view/ApplicationView.java b/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/view/ApplicationView.java
index 248f64474a..2b782c2a1d 100644
--- a/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/view/ApplicationView.java
+++ b/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/view/ApplicationView.java
@@ -12,10 +12,10 @@ package com.baeldung.hibernate.criteria.view;
import java.util.List;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Predicate;
-import javax.persistence.criteria.Root;
+import jakarta.persistence.criteria.CriteriaBuilder;
+import jakarta.persistence.criteria.CriteriaQuery;
+import jakarta.persistence.criteria.Predicate;
+import jakarta.persistence.criteria.Root;
import org.hibernate.Session;
import org.hibernate.query.Query;
diff --git a/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/view/EmployeeCriteriaQueries.java b/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/view/EmployeeCriteriaQueries.java
index f8c525611b..9303fd893e 100644
--- a/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/view/EmployeeCriteriaQueries.java
+++ b/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteria/view/EmployeeCriteriaQueries.java
@@ -3,9 +3,9 @@ package com.baeldung.hibernate.criteria.view;
import com.baeldung.hibernate.criteria.model.Employee;
import com.baeldung.hibernate.criteria.util.HibernateUtil;
import java.util.List;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Root;
+import jakarta.persistence.criteria.CriteriaBuilder;
+import jakarta.persistence.criteria.CriteriaQuery;
+import jakarta.persistence.criteria.Root;
import org.hibernate.Session;
import org.hibernate.query.Query;
diff --git a/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteriaquery/Student.java b/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteriaquery/Student.java
index 314e7ca557..af6b561091 100644
--- a/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteriaquery/Student.java
+++ b/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/criteriaquery/Student.java
@@ -1,11 +1,11 @@
package com.baeldung.hibernate.criteriaquery;
-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 = "students")
diff --git a/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/customtypes/LocalDateStringJavaDescriptor.java b/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/customtypes/LocalDateStringJavaDescriptor.java
index 56be9e693f..58d8e8628a 100644
--- a/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/customtypes/LocalDateStringJavaDescriptor.java
+++ b/persistence-modules/hibernate-queries/src/main/java/com/baeldung/hibernate/customtypes/LocalDateStringJavaDescriptor.java
@@ -1,14 +1,15 @@
package com.baeldung.hibernate.customtypes;
-import org.hibernate.type.LocalDateType;
-import org.hibernate.type.descriptor.WrapperOptions;
-import org.hibernate.type.descriptor.java.AbstractTypeDescriptor;
-import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
-import org.hibernate.type.descriptor.java.MutabilityPlan;
import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
-public class LocalDateStringJavaDescriptor extends AbstractTypeDescriptor {
+import org.hibernate.type.descriptor.WrapperOptions;
+import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
+
+import io.hypersistence.utils.hibernate.type.array.internal.AbstractArrayTypeDescriptor;
+
+public class LocalDateStringJavaDescriptor extends AbstractArrayTypeDescriptor {
public static final LocalDateStringJavaDescriptor INSTANCE = new LocalDateStringJavaDescriptor();
@@ -18,12 +19,12 @@ public class LocalDateStringJavaDescriptor extends AbstractTypeDescriptor implements DiscriminatorType {
+public class LocalDateStringType extends AbstractSingleColumnStandardBasicType {
public static final LocalDateStringType INSTANCE = new LocalDateStringType();
public LocalDateStringType() {
- super(VarcharTypeDescriptor.INSTANCE, LocalDateStringJavaDescriptor.INSTANCE);
+ super(VarcharJdbcType.INSTANCE, LocalDateStringJavaDescriptor.INSTANCE);
}
@Override
@@ -21,14 +19,12 @@ public class LocalDateStringType extends AbstractSingleColumnStandardBasicTypeHibernate EntityManager Demo
true
-
+
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/criteria/HibernateCriteriaIntegrationTest.java b/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/criteria/HibernateCriteriaIntegrationTest.java
index a1f88f3387..c405eb9ebd 100644
--- a/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/criteria/HibernateCriteriaIntegrationTest.java
+++ b/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/criteria/HibernateCriteriaIntegrationTest.java
@@ -15,10 +15,10 @@ import com.baeldung.hibernate.criteria.model.Item;
import com.baeldung.hibernate.criteria.util.HibernateUtil;
import com.baeldung.hibernate.criteria.view.ApplicationView;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaDelete;
-import javax.persistence.criteria.CriteriaUpdate;
-import javax.persistence.criteria.Root;
+import jakarta.persistence.criteria.CriteriaBuilder;
+import jakarta.persistence.criteria.CriteriaDelete;
+import jakarta.persistence.criteria.CriteriaUpdate;
+import jakarta.persistence.criteria.Root;
public class HibernateCriteriaIntegrationTest {
diff --git a/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/criteriaquery/TypeSafeCriteriaIntegrationTest.java b/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/criteriaquery/TypeSafeCriteriaIntegrationTest.java
index cedba412d9..bfcb4301a7 100644
--- a/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/criteriaquery/TypeSafeCriteriaIntegrationTest.java
+++ b/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/criteriaquery/TypeSafeCriteriaIntegrationTest.java
@@ -1,6 +1,5 @@
package com.baeldung.hibernate.criteriaquery;
-import com.baeldung.hibernate.criteriaquery.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
@@ -10,9 +9,9 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Root;
+import jakarta.persistence.criteria.CriteriaBuilder;
+import jakarta.persistence.criteria.CriteriaQuery;
+import jakarta.persistence.criteria.Root;
import java.io.IOException;
import java.util.List;
diff --git a/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/distinct/entities/DistinctHqlQueriesUnitTest.java b/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/distinct/entities/DistinctHqlQueriesUnitTest.java
index 799439a51b..3ce384741f 100644
--- a/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/distinct/entities/DistinctHqlQueriesUnitTest.java
+++ b/persistence-modules/hibernate-queries/src/test/java/com/baeldung/hibernate/distinct/entities/DistinctHqlQueriesUnitTest.java
@@ -8,7 +8,6 @@ import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.annotations.QueryHints;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -45,12 +44,12 @@ public class DistinctHqlQueriesUnitTest {
}
@Test
- public void whenExecutingSelectQuery_thereWillBeDuplicates() {
+ public void whenExecutingSelectQuery_thereTheInsertedPosts() {
String hql = "SELECT p FROM Post p LEFT JOIN FETCH p.comments";
List posts = session.createQuery(hql, Post.class)
.getResultList();
- assertThat(posts).hasSize(3);
+ assertThat(posts).hasSize(1);
}
@Test
@@ -68,8 +67,8 @@ public class DistinctHqlQueriesUnitTest {
@Test
public void whenExecutingSelectDistinctQueryWithHint_thereShouldBeNoDuplicates() {
String hql = "SELECT DISTINCT p FROM Post p LEFT JOIN FETCH p.comments";
+ // From Hibernate ORM 6, distinct is always passed to the SQL query and the flag QueryHints#HINT_PASS_DISTINCT_THROUGH has been removed.
List posts = session.createQuery(hql, Post.class)
- .setHint(QueryHints.PASS_DISTINCT_THROUGH, false)
.getResultList();
assertThat(posts).hasSize(1)
diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml
index ad757d9073..fc83233492 100644
--- a/persistence-modules/pom.xml
+++ b/persistence-modules/pom.xml
@@ -26,15 +26,14 @@
flyway-repair
hbase
hibernate5
-
+ hibernate-mapping
hibernate-mapping-2
-
+ hibernate-annotations
hibernate-exceptions
hibernate-libraries
hibernate-jpa
-
-
+ hibernate-queries
+ hibernate-enterprise
influxdb
java-cockroachdb
@@ -116,7 +115,7 @@
6.2.0.Final
42.5.4
- 2.3.4
+ 2.7.1
1.16.3
diff --git a/pom.xml b/pom.xml
index 060f3a0738..996ebdc459 100644
--- a/pom.xml
+++ b/pom.xml
@@ -367,6 +367,7 @@
muleesb
persistence-modules/deltaspike
+ persistence-modules/hibernate-ogm
@@ -552,6 +553,7 @@
muleesb
persistence-modules/deltaspike
+ persistence-modules/hibernate-ogm
diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/customizederrorhandling/client/ProductClient.java b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/customizederrorhandling/client/ProductClient.java
index f668e8f2c8..470dd5c929 100644
--- a/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/customizederrorhandling/client/ProductClient.java
+++ b/spring-cloud-modules/spring-cloud-openfeign/src/main/java/com/baeldung/cloud/openfeign/customizederrorhandling/client/ProductClient.java
@@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import com.baeldung.cloud.openfeign.customizederrorhandling.config.FeignConfig;
import com.baeldung.cloud.openfeign.defaulterrorhandling.model.Product;
-@FeignClient(name = "product-client-2", url = "http://localhost:8081/product/", configuration = FeignConfig.class)
+@FeignClient(name = "product-client-2", url = "http://localhost:8088/product/", configuration = FeignConfig.class)
public interface ProductClient {
@RequestMapping(value = "{id}", method = RequestMethod.GET)
diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/test/java/com/baeldung/cloud/openfeign/customizederrorhandling/client/ProductClientUnitTest.java b/spring-cloud-modules/spring-cloud-openfeign/src/test/java/com/baeldung/cloud/openfeign/customizederrorhandling/client/ProductClientUnitTest.java
index 5e715265aa..385ce900f5 100644
--- a/spring-cloud-modules/spring-cloud-openfeign/src/test/java/com/baeldung/cloud/openfeign/customizederrorhandling/client/ProductClientUnitTest.java
+++ b/spring-cloud-modules/spring-cloud-openfeign/src/test/java/com/baeldung/cloud/openfeign/customizederrorhandling/client/ProductClientUnitTest.java
@@ -31,8 +31,8 @@ public class ProductClientUnitTest {
@Before
public void startWireMockServer() {
- wireMockServer = new WireMockServer(8081);
- configureFor("localhost", 8081);
+ wireMockServer = new WireMockServer(8088);
+ configureFor("localhost", 8088);
wireMockServer.start();
}
diff --git a/spring-cloud-modules/spring-cloud-openfeign/src/test/java/com/baeldung/cloud/openfeign/customizederrorhandling/controller/ProductControllerUnitTest.java b/spring-cloud-modules/spring-cloud-openfeign/src/test/java/com/baeldung/cloud/openfeign/customizederrorhandling/controller/ProductControllerUnitTest.java
index d46c6fd86f..3d103d1333 100644
--- a/spring-cloud-modules/spring-cloud-openfeign/src/test/java/com/baeldung/cloud/openfeign/customizederrorhandling/controller/ProductControllerUnitTest.java
+++ b/spring-cloud-modules/spring-cloud-openfeign/src/test/java/com/baeldung/cloud/openfeign/customizederrorhandling/controller/ProductControllerUnitTest.java
@@ -46,8 +46,8 @@ public class ProductControllerUnitTest {
@Before
public void startWireMockServer() {
- wireMockServer = new WireMockServer(8081);
- configureFor("localhost", 8081);
+ wireMockServer = new WireMockServer(8088);
+ configureFor("localhost", 8088);
wireMockServer.start();
}