AuditQuery and relationships

Forgot to ask one more thing - I assume i should be able to set the order to properties that belong to Parent. Is this correct?

@Naros I am getting exception: “… not yet implemented …”. In what exact version is your example supported?


java.lang.UnsupportedOperationException: Not yet implemented for revisions of entity queries
I am using envers version 5.4.1

@Naros - I apologize, but this is urgent and i am not sure if what I need is really supported in 5.4.1?

This is how the implementation looks like:
public AuditAssociationQuery<? extends AuditQuery> traverseRelation(String associationName, JoinType joinType) {
throw new UnsupportedOperationException( “Not yet implemented for revisions of entity queries” );

When you wrote your example, you must have had certain implementation in mind - certainly not the one in 5.4.1 - right?

Yes, so long as the relation is a to-one, you can simply traverse the object-graph as nested as you need and apply the appropriate predicates to filter the results.

I’m not clear on what you’re asking here.

My apologies, you’re correct the RevisionsOfEntityQuery does not yet support this feature; I simply wrote an example to illustrate the syntax and overlooked that. The other two query implementations should work, EntitiesModifiedAtRevisionQuery and EntitiesAtRevisionQuery.

I assume you need to be able to fetch a list of revisions based on predicates rather than knowing the revision numbers ahead of time?

About the order - I need to sort on a property of ‘toOne’ entity.
About the query - Yes, I need a list of revisions filtered by a property of ‘toOne’ entity.

Do you have any idea when will this be available? I would even take ‘code in development’, as long as it can be used for couple of scenarios I need! (that’s how desperate i am :slight_smile:

@Naros - Any hint here?

Is this implemented in Alpha2? If not, is there any info when will it be implemented?

Hi @gbakalar

A number of the new Envers features such as to-many traversal support is not yet in 6.0’s alpha stream as we’ve been more focused on getting hibernate-core stable with all the necessary features. It’s really difficult to flush out and implement behavior in a submodule when the main module does not yet support and implement all the necessary features to build upon in the first place, so its all very much a work in progress stream of changes.

I will need to double check if this is something the feature branch supports. Is the to-one order-by the only sorting you need or do you need sorting on other parts of the domain model, such as the root/parent too?

I’ll take a look and see if we cannot get that implemented in 5.x for RevisionsOfEntity queries to work around the UnsupportedOperationException that the code currently throws. I can’t give you a specific timeline of when I’ll get it working as my time is split among several development projects right now, but I’ll do my best to get it done asap.

I am not sure I understand this question. If I have relationship Child->Parent, and columns Child.c1, Parent.p1, the minimum I would need is sort on either Child.c1, or Parent.p1 (no need together, but just one of them).

Thank you very much!

What I was trying to understand was whether you need to effectively write an order-by fragment that looked something like "ORDER BY child.fieldX DESC, parent.fieldA ASC" . This is what I am not sure if the current implementation is capable of supporting when it comes to traversals.

At this point no, but of course it would be nice to have once you have time to implement it.

Hello @Naros,

Did you have any chance to look into this so far?


I totally understand that 6.0 is a huge undertaking, but is there any chance somebody can take a look into this problem? Sadly, I cannot find any workaround…

Hi @gbakalar, I am sorry to get back to this so late. I believe I may have a solution for 5.4 though I need to polish up the code a bit and add a few more test cases to verify that it works.


Thank you for your reply. Please let me know when you are complete with the 5.4 code, it will help a lot.

Btw, will it be in 6.0?



Hi @gbakalar, indeed. Any change made in 5.4 is being periodically merged into the 6.0 code base on intervals as the team is still actively fixing and improving 5.4 in parallel.

what is workaround?
How it will be helpful it audit query?

Hi again - is this ever solved?

1 Like