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

Envers throws MappingException: Type not supported for auditing #463

Closed
msdousti opened this issue Jul 31, 2022 · 4 comments
Closed

Envers throws MappingException: Type not supported for auditing #463

msdousti opened this issue Jul 31, 2022 · 4 comments
Milestone

Comments

@msdousti
Copy link
Contributor

Synopsis

ImmutableType and its descendants like PostgreSQLHStoreType are not compatible with Envers.
For instance, consider the following @Audited Entity:

import com.vladmihalcea.hibernate.type.basic.PostgreSQLHStoreType;

// ...
@Entity
@TypeDef(name = "PostgreSQLHStoreType", typeClass = PostgreSQLHStoreType.class)
@Audited
public class Post {
    @Id
    private Long id;

    @Type(type = "PostgreSQLHStoreType")
    @Column(columnDefinition = "hstore")
    private Map<String, String> translations;

    // ...
}

It will cause an

org.hibernate.MappingException: Type not supported for auditing: com.vladmihalcea.hibernate.type.basic.PostgreSQLHStoreType

exception upon building the session factory.

Test

A full-fledged test along with explanations can be found here.

Fix

ImmutableType can be modified to implement BasicType instead of Type, as explained here.

Suggestion

I can open a PR for applying the above change.

@vladmihalcea
Copy link
Owner

Looking forward to your Pull Request that fixes this issue

msdousti added a commit to msdousti/hibernate-types that referenced this issue Aug 1, 2022
Envers expects (simple) audited types to implement the BasicType
interface. This commit changes The ImmutableType to implement BasicType
rather than Type.

The commit is work in progress: It only applies the change to
hibernate-types-55 as a template. If the change is OK, it will be
applied to other hibernate-types-* as well.

Resolves: vladmihalcea#463
@msdousti
Copy link
Contributor Author

msdousti commented Aug 1, 2022

Thanks a lot for considering my suggestion. I created #464 for hibernate-types-55. If the changes there are OK, I'll replicate them to other hibernate-types-* modules in the same PR.

Incidentally, I noted that the PR also fixes this:
https://stackoverflow.com/q/69313708/459391

@vladmihalcea vladmihalcea changed the title MappingException: Type not supported for auditing Envers throws MappingException: Type not supported for auditing Aug 3, 2022
@vladmihalcea vladmihalcea added this to the 2.17.2 milestone Aug 3, 2022
@vladmihalcea
Copy link
Owner

I'll integrate it after I apply the same login to the new ImmutableCompositeType

@vladmihalcea
Copy link
Owner

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants