4 Replies Latest reply on Dec 12, 2010 3:12 AM by Pavel Vainer

    AuditEntity.property ClassCastException

    Pavel Vainer Newbie

      Hi!

       

      I have a problem finding all the revisions for the given entity.

      FIrst, I needed to find all the revisions by the entity id and it worked fine using the following:

       

       

      reader.createQuery().forRevisionsOfEntity(Class.forName(className),
      false, false).add(AuditEntity.id().eq(id)).add(
      AuditEntity.revisionProperty("name").ne("")).add(AuditEntity.revisionProperty("versionType").eq(versionType.getName())).getResultList();

      reader.createQuery().forRevisionsOfEntity(Class.forName(className), false, false)

           .add(AuditEntity.id().eq(id))

           .add(AuditEntity.revisionProperty("name").ne(""))

           .add(AuditEntity.revisionProperty("versionType").eq(versionType.getName()))

           .getResultList();

       

       

      Than, the requirement was changed and the parameter used is the field "originalId". I've changed the code as shown:

       

       

      reader.createQuery().forRevisionsOfEntity(Class.forName(className), false, false)

           .add(AuditEntity.property("originalId").eq(id)) //Long id

           .add(AuditEntity.revisionProperty("name").ne(""))

           .add(AuditEntity.revisionProperty("versionType").eq(versionType.getName()))

           .getResultList();

       

      But now the ClassCastException is thrown

      java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map

       

      Long - type of id

       

      Any suggestions?

       

      Thank you

      Pavel