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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:19:50+00:00 2026-05-24T12:19:50+00:00

So my problem is that I need to find all the recently deleted entities

  • 0

So my problem is that I need to find all the recently deleted entities of a particular class, that is the entities which have been deleted since a particular timestamp. Specifically, I want to find entities deleted within the last hour.

All my entities have a created and updated timestamp which I maintain correctly with a listener:

@NotNull
@Column(name = "updated")
@Type(type="org.joda.time.contrib.hibernate.PersistentDateTime")
private DateTime updated;

I also use Envers and annotate my entities.

So to guess, my query should start like this:

// Query for deleted bookings
AuditReader reader = AuditReaderFactory.get(entityManager);
AuditQuery query = reader.createQuery()
.forRevisionsOfEntity(Booking.class, false, true)

but I don’t know what to put here to find the deleted Booking’s since a DateTime.

  • 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-24T12:19:51+00:00Added an answer on May 24, 2026 at 12:19 pm

    First, get a timestamp for one hour ago (in milliseconds):

    long timestamp = (System.getCurrentTimeMillis()) - (60*60*1000);
    

    Then you can query relative to the timestamp:

    AuditReader reader = AuditReaderFactory.get(entityManager);
    AuditQuery query = reader.createQuery()
    .forRevisionsOfEntity(Booking.class, false, true)
    .add(AuditEntity.revisionProperty("timestamp").gt(timestamp)
    .add(AuditEntity.revisionType().eq(RevisionType.DEL));
    
    List<Object[]> results = query.getResultList();
    

    to get the revision data. Each Object[] has

    1. revision meta data (DefaultRevisionEntity or your own class annotated with @RevisionEntity(CustomRevisionListener.class))
    2. the entity instance (the Booking in this case)
    3. the RevisionType, which we know will always be DEL in this case
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem: I need to find all active [GiftPledges] that have the last three
I need to find an element that has a particular title. The only problem
I have a problem with reflection. I need to find the type that instantiates
I need to find all the classes derived from System.Web.UI.Page which reference another class
Often i have a problem that I need to determine which assebmly to include
I have an interesting SQL problem that I need help with. Here is the
The problem is this: I have multiple competing threads (100+) that need to access
I've got a problem about onbeforeunload recently that I need to pop up a
I need to use something like get_or_create() but the problem is that I have
We have recently been faced with the problem of porting our C++ framework to

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.