Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4061140
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:25:44+00:00 2026-05-20T15:25:44+00:00

I use Hibernate Envers for auditing. My entity looks like this: @Entity @Audited public

  • 0

I use Hibernate Envers for auditing. My entity looks like this:

@Entity
@Audited
public class Child
{
    @GeneratedValue
    @Id
    @Column
    private Long id;

    @Column
    private String test;

    // getters & setters
}

Now I would like to query revisions like this:

query = reader.createQuery().forRevisionsOfEntity(Child.class, false, true);
query.add(AuditEntity.property("test").eq("child1"));

Long id = ...;
query = reader.createQuery().forRevisionsOfEntity(Child.class, false, true);
query.add(AuditEntity.property("id").eq(id));

The first query works, executing the second throws the following exception:

java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map
    at org.hibernate.property.MapAccessor$MapGetter.get(MapAccessor.java:118)
    at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:77)
    at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:83)
    at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:381)
    at org.hibernate.type.ComponentType.nullSafeGetValues(ComponentType.java:354)
    at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:309)
    at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:67)
    at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:567)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1612)
    at org.hibernate.loader.Loader.doQuery(Loader.java:717)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
    at org.hibernate.loader.Loader.doList(Loader.java:2294)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2172)
    at org.hibernate.loader.Loader.list(Loader.java:2167)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:448)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at org.hibernate.envers.query.impl.AbstractAuditQuery.buildAndExecuteQuery(AbstractAuditQuery.java:95)
    at org.hibernate.envers.query.impl.RevisionsOfEntityQuery.list(RevisionsOfEntityQuery.java:104)
    at org.hibernate.envers.query.impl.AbstractAuditQuery.getResultList(AbstractAuditQuery.java:101)

I have no clue why this leads to a ClassCastException. Any idea, what I’m missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T15:25:45+00:00Added an answer on May 20, 2026 at 3:25 pm

    When comparing the ids of two audited entities, use AuditEntity.id() instead of AuditEntity.property().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to use Hibernate Envers to log the entity histroy. but failed. My
I would like to use hibernate-3.5-1.Final along with this plugin, what should be my
I am trying to use hibernate with annotations. I annotated my class with @Entity
I am trying to use Hibernate to do save/load objects that look like this
I have a table with properties defined like this : @Column(name=\SERIAL#\) When Hibernate inserts
I use hibernate 3.5.4-final. I have two JPA classes. @Entity @Table(name = SPI_V_OP_OBJ_SUBJECT_VR) public
I am trying to use Envers on a project that also uses Hibernate and
I'm attempting to use hibernate entity manager with mysql and glassfish. I'm getting the
I have a few Hibernate Envers listeners which I use for audit purposes. I
I would like to use hibernate for persisting objects through web services and am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.