Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate Envers: Problem querying revisions
    primarykey
    data
    text
    <p>I use Hibernate Envers for auditing. My entity looks like this:</p> <pre><code>@Entity @Audited public class Child { @GeneratedValue @Id @Column private Long id; @Column private String test; // getters &amp; setters } </code></pre> <p>Now I would like to query revisions like this:</p> <pre><code>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)); </code></pre> <p>The first query works, executing the second throws the following exception:</p> <pre><code>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) </code></pre> <p>I have no clue why this leads to a ClassCastException. Any idea, what I'm missing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload