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

  • Home
  • SEARCH
  • 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 8810859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:13:16+00:00 2026-06-14T03:13:16+00:00

I have the following simple data structure (details omitted for brevity): @Audited @Entity class

  • 0

I have the following simple data structure (details omitted for brevity):

@Audited
@Entity
class SettingsGroup implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    Integer id

    @OneToMany(mappedBy = "group", cascade = [CascadeType.ALL])
    @OrderBy("key")
    List<SettingsEntry> entries = []

}



@Audited
@Entity
class SettingsEntry implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    Integer id

    @ManyToOne
    SettingsGroup group

}

I’ve set the org.hibernate.envers.store_data_at_delete=true flag. Upon fetching the revisions for SettingsEntry, it will throw an EntityNotFoundException while trying to lazy fetch the associated group from the _aud table.

def reader = AuditReaderFactory.get(manager)
def query = reader.createQuery().forRevisionsOfEntity(SettingsEntry, false, true)
audits = query.resultList.collect {
    //noinspection GroovyAssignabilityCheck
    new AuditRevision<T>(entity:it[0], revision: it[1], type: it[2])
}   

I took a look at the SQL generated and it appears to be filtering out delete revision types while trying to fetch the parent record which causes no records to show up:

select *
from settings_group_aud sg 
where sg.rev=(
  select max(sg2.rev) from settings_group_aud sg2 where sg2.rev<=3 and sg.id=sg2.id
) and sg.revtype<>2 and sg.id=1

There are records in the table.. it just that the most recent is a delete:

select * from SETTINGS_GROUP_AUD;
ID      NAME    ENVIRONMENT     KEY_NAME    REV     REVTYPE  
1   test    prod    Default Key 2   0
1   test    prod    Default Key 3   2
(2 rows, 1 ms)

Is there a way to tweak the lazy initialization within Envers to prevent the filtering of deleted rev types? That would fix my problem. I’m just not seeing anything which is configurable.

My other option is to just off org.hibernate.envers.store_data_at_delete again but I’d prefer to keep it on if possible. This seems a little like a bug but I’m new to Envers so maybe I’m just looking at this all wrong 🙂

  • 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-06-14T03:13:17+00:00Added an answer on June 14, 2026 at 3:13 am

    Unfortunately that looks like a bug when navigating a deleted entity’s graph. Please report to https://hibernate.onjira.com/secure/Dashboard.jspa.

    The solution probably would be not to select the deleted entities in the query: forRevisionsOfEntity(SettingsEntry, false, false). The last element of the list will then be the entity as it was when it was deleted.

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

Sidebar

Related Questions

I have the following simple structure: Applicant Possition ApplicantPosition and ApplicantPositionHistory The 3rd class
I have the following simple data structure. A list of students, each with a
I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
I have the following simple class definition: //mycommon.h @interface CurrentPath : NSObject @property (nonatomic,
Let's say I have the following structure declaration (simple struct with no constructor). struct
Let's say I have this simple structure class FooDefinition { public FooDefinition Parent {
I have the following simple model example: #include <QtGui/QApplication> #include <QtGui/QTreeView> #include <QAbstractItemModel> class
I have a structure similar to the following: /root/ /root/data/ /root/data/script.php /root/data/some.json /root/data/feature/one.json /root/data/feature/two.json
I have the following data structure for a movies SQLite db (i will keep
Let's say I have the following hypothetical data structure: create table country ( country_id

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.