Using EntityLogAttr in JPQL

I am working on what could be classified as a an auditing report. I need to show a list Orders where the quantity, price, or ship date has changed as well as the old and new values. I’ve constructed a JPQL query that can pull up all the EntityLog instances for my Order entity but I’m running into a wall in how to access the attributes to find current and old values for the above three fields. I’ve tried a join on the attributes property by that did not work (I assume because it is a @MetaProperty). I’m not sure which direction to move now.

I suspect a Groovy script would work but I’m not sure how to merge the JPQL query I have to get the EntityLog instances and then the Groovy script to access the attributes.

You are right, EntityLogAttr entity is not persistent and cannot be used in queries. However, if you load the list of EntityLogItem instances, each item will contain the collection of EntityLogAttr instances. So you could display the attributes or filter your EntityLogItem collection in memory.

If you really need to search in the database by an old attribute value, create a database function for searching in the CHANGES field according to its format, and call the function in JPQL using where function('MY_DB_FUNC', ...) = ...