diff --git a/hibernate-types-55/pom.xml b/hibernate-types-55/pom.xml
index a88ce0b3e..9f5f47fff 100644
--- a/hibernate-types-55/pom.xml
+++ b/hibernate-types-55/pom.xml
@@ -24,6 +24,13 @@
provided
+
+ org.hibernate
+ hibernate-envers
+ ${hibernate.version}
+ test
+
+
com.fasterxml.jackson.core
jackson-databind
diff --git a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java
index 6d99cf7ab..501bbc05a 100644
--- a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java
+++ b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java
@@ -6,6 +6,7 @@
import com.vladmihalcea.hibernate.type.interval.PostgreSQLIntervalType;
import com.vladmihalcea.hibernate.type.interval.PostgreSQLPeriodType;
import com.vladmihalcea.hibernate.type.json.*;
+import com.vladmihalcea.hibernate.type.money.MonetaryAmountType;
import com.vladmihalcea.hibernate.type.range.PostgreSQLRangeType;
import com.vladmihalcea.hibernate.type.range.guava.PostgreSQLGuavaRangeType;
import com.vladmihalcea.hibernate.type.search.PostgreSQLTSVectorType;
@@ -16,6 +17,8 @@
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.BasicType;
+import org.hibernate.type.Type;
+import org.hibernate.usertype.CompositeUserType;
import org.hibernate.usertype.UserType;
/**
@@ -92,21 +95,22 @@ public void contribute(TypeContributions typeContributions, ServiceRegistry serv
.contributeType(typeContributions, YearMonthEpochType.INSTANCE)
.contributeType(typeContributions, YearMonthIntegerType.INSTANCE)
.contributeType(typeContributions, YearMonthTimestampType.INSTANCE)
+ .contributeType(typeContributions, MonetaryAmountType.INSTANCE)
/* JSON */
.contributeType(typeContributions, JsonType.INSTANCE);
}
- private HibernateTypesContributor contributeType(TypeContributions typeContributions, BasicType type) {
- typeContributions.contributeType(type);
- return this;
- }
-
- private HibernateTypesContributor contributeType(TypeContributions typeContributions, UserType type) {
- if(type instanceof ImmutableType) {
- ImmutableType immutableType = (ImmutableType) type;
- typeContributions.contributeType(immutableType, immutableType.getName());
+ private HibernateTypesContributor contributeType(TypeContributions typeContributions, Object type) {
+ if (type instanceof BasicType) {
+ typeContributions.contributeType((BasicType) type);
+ } else if (type instanceof UserType) {
+ typeContributions.contributeType((UserType) type, type.getClass().getSimpleName());
+ } else if (type instanceof CompositeUserType) {
+ typeContributions.contributeType((CompositeUserType) type, type.getClass().getSimpleName());
} else {
- typeContributions.contributeType(type, type.getClass().getSimpleName());
+ throw new UnsupportedOperationException(
+ String.format("The [%s] is not supported!", type.getClass())
+ );
}
return this;
}
diff --git a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/ImmutableCompositeType.java b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/ImmutableCompositeType.java
index a2f20c1d6..256f94023 100644
--- a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/ImmutableCompositeType.java
+++ b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/ImmutableCompositeType.java
@@ -8,11 +8,11 @@
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.ArrayHelper;
+import org.hibernate.type.BasicType;
import org.hibernate.type.ForeignKeyDirection;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.java.IncomparableComparator;
import org.hibernate.usertype.CompositeUserType;
-import org.hibernate.usertype.UserType;
import java.io.Serializable;
import java.sql.PreparedStatement;
@@ -33,7 +33,7 @@
*
* @author Vlad Mihalcea
*/
-public abstract class ImmutableCompositeType implements CompositeUserType, Type {
+public abstract class ImmutableCompositeType implements CompositeUserType, BasicType {
private final Configuration configuration;
@@ -326,4 +326,9 @@ public Object replace(Object original, Object target, SharedSessionContractImple
public boolean[] toColumnNullness(Object value, Mapping mapping) {
return value == null ? ArrayHelper.FALSE : ArrayHelper.TRUE;
}
+
+ @Override
+ public String[] getRegistrationKeys() {
+ return new String[]{getName()};
+ }
}
\ No newline at end of file
diff --git a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/ImmutableType.java b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/ImmutableType.java
index 50350ee4c..24cf79dd0 100644
--- a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/ImmutableType.java
+++ b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/ImmutableType.java
@@ -8,10 +8,10 @@
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.ArrayHelper;
+import org.hibernate.type.BasicType;
import org.hibernate.type.ForeignKeyDirection;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.java.IncomparableComparator;
-import org.hibernate.type.spi.TypeBootstrapContext;
import org.hibernate.usertype.UserType;
import java.io.Serializable;
@@ -29,7 +29,7 @@
*
* @author Vlad Mihalcea
*/
-public abstract class ImmutableType implements UserType, Type {
+public abstract class ImmutableType implements UserType, BasicType {
private final Configuration configuration;
@@ -320,4 +320,9 @@ public Object replace(Object original, Object target, SharedSessionContractImple
public boolean[] toColumnNullness(Object value, Mapping mapping) {
return value == null ? ArrayHelper.FALSE : ArrayHelper.TRUE;
}
+
+ @Override
+ public String[] getRegistrationKeys() {
+ return new String[]{getName()};
+ }
}
\ No newline at end of file
diff --git a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/money/MonetaryAmountType.java b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/money/MonetaryAmountType.java
index 86b72525b..e350ae8e0 100644
--- a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/money/MonetaryAmountType.java
+++ b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/money/MonetaryAmountType.java
@@ -30,6 +30,8 @@
*/
public class MonetaryAmountType extends ImmutableCompositeType {
+ public static final MonetaryAmountType INSTANCE = new MonetaryAmountType();
+
public MonetaryAmountType() {
super(MonetaryAmount.class);
}
diff --git a/hibernate-types-55/src/test/java/com/vladmihalcea/hibernate/type/basic/PostgreSQLHStoreTypeTest.java b/hibernate-types-55/src/test/java/com/vladmihalcea/hibernate/type/basic/PostgreSQLHStoreTypeTest.java
index 9d5a83f15..b4d5fe9b3 100644
--- a/hibernate-types-55/src/test/java/com/vladmihalcea/hibernate/type/basic/PostgreSQLHStoreTypeTest.java
+++ b/hibernate-types-55/src/test/java/com/vladmihalcea/hibernate/type/basic/PostgreSQLHStoreTypeTest.java
@@ -5,6 +5,7 @@
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
+import org.hibernate.envers.Audited;
import org.junit.Test;
import javax.persistence.*;
@@ -67,6 +68,7 @@ public void test() {
});
}
+ @Audited
@Entity(name = "Book")
@Table(name = "book")
@TypeDef(name = "hstore", typeClass = PostgreSQLHStoreType.class)
diff --git a/hibernate-types-55/src/test/java/com/vladmihalcea/hibernate/type/money/MySQLMonetaryAmountTypeTest.java b/hibernate-types-55/src/test/java/com/vladmihalcea/hibernate/type/money/MySQLMonetaryAmountTypeTest.java
index c6ea0cd2b..b9f0a18d1 100644
--- a/hibernate-types-55/src/test/java/com/vladmihalcea/hibernate/type/money/MySQLMonetaryAmountTypeTest.java
+++ b/hibernate-types-55/src/test/java/com/vladmihalcea/hibernate/type/money/MySQLMonetaryAmountTypeTest.java
@@ -4,6 +4,7 @@
import org.hibernate.annotations.Columns;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
+import org.hibernate.envers.Audited;
import org.javamoney.moneta.Money;
import org.junit.Test;
@@ -90,6 +91,7 @@ public void testReturnNullMoney() {
});
}
+ @Audited
@Entity(name = "Salary")
@Table(name = "salary")
@TypeDef(name = "monetary-amount-currency", typeClass = MonetaryAmountType.class, defaultForType = MonetaryAmount.class)