Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Envers compatibility with ImmutableType #464

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions hibernate-types-55/pom.xml
Expand Up @@ -24,6 +24,13 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>${hibernate.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
Expand Down
Expand Up @@ -101,13 +101,13 @@ private HibernateTypesContributor contributeType(TypeContributions typeContribut
return this;
}

private HibernateTypesContributor contributeType(TypeContributions typeContributions, ImmutableType<?> 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());
} else {
typeContributions.contributeType(type, type.getClass().getSimpleName());
}
typeContributions.contributeType(type, type.getClass().getSimpleName());
return this;
}
}
Expand Up @@ -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;
Expand All @@ -29,7 +29,7 @@
*
* @author Vlad Mihalcea
*/
public abstract class ImmutableType<T> implements UserType, Type {
public abstract class ImmutableType<T> implements UserType, BasicType {

private final Configuration configuration;

Expand Down Expand Up @@ -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()};
}
}
Expand Up @@ -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.*;
Expand Down Expand Up @@ -67,6 +68,7 @@ public void test() {
});
}

@Audited
@Entity(name = "Book")
@Table(name = "book")
@TypeDef(name = "hstore", typeClass = PostgreSQLHStoreType.class)
Expand Down