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 6763583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:29:37+00:00 2026-05-26T14:29:37+00:00

I have not been using envers for very long, and i have hit a

  • 0

I have not been using envers for very long, and i have hit a problem i just cant seem to find the answer to anywhere. I have tried googling the stack trace but to no avail, so i must be missing something blindingly obvious.
I seem to get the following stack trace whenever i try to run the ‘find(class, versionNumber)’ method in org.hibernate.envers.AuditReader in order to retrieve a previous version of a Document class in the database:

java.lang.NullPointerException
org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:91)
org.hibernate.envers.entities.EntityInstantiator.addInstancesFromVersionsEntities(EntityInstantiator.java:113)
org.hibernate.envers.query.impl.EntitiesAtRevisionQuery.list(EntitiesAtRevisionQuery.java:110)
org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:108)
org.hibernate.envers.reader.AuditReaderImpl.find(AuditReaderImpl.java:119)
org.hibernate.envers.reader.AuditReaderImpl.find(AuditReaderImpl.java:94)
com.example.repository.AbstractDocumentTypeManager.getVersion(AbstractDocumentTypeManager.java:221)
com.example.repository.AbstractDocumentTypeManager.getVersion(AbstractDocumentTypeManager.java:1)
com.example.logic.versioning.BaseVersioningService.getApprovedSnapshot(BaseVersioningService.java:54)
com.example.logic.versioning.BaseVersioningService$$FastClassByCGLIB$$d33887d.invoke(<generated>)
net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
...

The code which causes this error is below. It takes place after my Document is saved and it seems that the appropriate version is being created in the database (document_AUD).

public Document getVersion(String objectId, Number version) {
    AuditReader auditReader = getAuditReader();
    /* at this point, i guarantee that neither objectId nor version are null. */
    Document revision = auditReader.find(Document.class, objectId, version);
    return revision;
}

public AuditReader getAuditReader() {
    return AuditReaderFactory.get(entityManager);
}

My ‘Document’ class is annotated like so…

@Entity(name = "document")
@DiscriminatorColumn(name = "DTYPE", discriminatorType = DiscriminatorType.STRING)
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
@Cacheable(true)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "modelObjectCache")
public abstract class Document<T extends Document<?>> extends ModelObject implements Serializable, Comparable<T>,
    Versionable {
    /* many properties of a Document here. There are 2 subclasses of Document, identified by a database discriminator. */
}

Please let me know you need any more code in order to properly find this problem.

Many thanks for reading and any suggestions are welcome,

rich.

  • 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-26T14:29:37+00:00Added an answer on May 26, 2026 at 2:29 pm

    Alright, i seem to have found the answer – when you run the find method on AuditReader, you have to actually send the implementing class rather than the abstract superclass.
    so, for example where i say,

    Document revision = auditReader.find(Document.class, objectId, version);
    

    i actually need to put:

    Document revision = auditReader.find(DocumentImplementation.class, objectId, version);
    

    Marvellous.

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

Sidebar

Related Questions

How to write this in C#.NET, I have not been encountered using the ^
Following the standard instruction for using AES algorithm, I have not been able to
I have been using emacs for a while but not so familiar with lisp
I have been using this as a reference, but not able to accomplish exactly
I have not been able to find a way to cancel/terminate asynchronous read operation
I have not been able to find any definitive answers to this question: Can
So this is something that I have not been able to find any documentation
I've been working on this problem for quite a while but have not been
I have been using @selector today for the first time and have not been
I want to create an ASP.NET web site. I have not been using ASP.NET

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.