Hibernate envers not able to recognize custom types created using @TypeDef annotations from hibernate-types library .
I have an entity, that uses custom type PostgreSQLInetType.class:
@Entity
@Table(name = "my_acl")
@TypeDef(typeClass = PostgreSQLInetType.class, defaultForType = Inet.class)
@Audited
public class MyAcl {
Inet acl;
//other fields, getters\setters etc.
}
But during my SpringBoot application start, I'm getting the following exception:
Caused by: org.hibernate.MappingException: Type not supported for auditing: com.vladmihalcea.hibernate.type.basic.PostgreSQLInetType, on entity org.acme.MyAcl, property 'acl'.
Is there any way to fix this or tell Envers how to map PostgreSQLInetType?
3条答案
按热度按时间vxbzzdmp1#
我在
hibernate-types
项目中创建了一个PR来解决此问题:https://github.com/vladmihalcea/hibernate-types/pull/464。PR被合并,您可以看到
ImmutableType
现在实现了BasicType
。请升级到hibernate-types版本2.17.3或更高版本以使此修复程序正常工作。
aiqt4smr2#
To be usable by Envers, the type would have to implement the
org.hibernate.type.BasicType
interface.pzfprimi3#
To use Audited annotation with custom hibernate type use
@Type(type = "com.example.StringBufferStringType") crate two files to configure the custom type and make sure do not return any specific string like "name" cause while creation of table the entity table might get created but while creation of Audit table it will throw an error like unable to determine the specificed column data type.
To resolve above issue return null
go through given link to get more insight on it.
https://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#basic-lob