You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For Entities with Long IDs this view does not work after restarting the application (empty Javers cache) and already having these entries in database:
It creates a request that produces an internal server error (500)
It took me quite some time to figure out the root cause for this issue and it has something to do with how Javers processes IDs and stores these in the jv_global_id table and then how it processes request for data in that table and how this blueprint makes use of that.
As you can see here, String IDs (like UUIDs) are quoted within the database table. Long ones are not quoted. That is happening completely in the background, i.e. nothing, the blueprint here can influence.
The problem is now with requests for showing changelog details.
The method is this one:
This one gets entityId as a String type, no matter, what the original entity's ID type was and passes that String on to Javers. Javers in turn passes this Object type further on, and converts it somehwhere internally to a JSON String to pass that further on into a prepared statement. So to the prepared statement, also Long / String is being passed for execution, which also contains the mentioned quotes in the String case, but since we do pass everything as String, also for the Long-ID type entities. A query log demonstrates the problem:
The red one is the query for a Long-ID based entity, while the geen one is the UUID-ID (String) based entity:
Therefore, nothing is being found and we run into an java.lang.IndexOutOfBoundsException on this line in the get(0):
(!) Please note in can only be reproduced when clearing the Javers internal cache for Global IDs to enforce loading it from database, by i.e. restarting the application. The internal cache itself is sort of resistent against this issue.
Possible solution: Pass in the ID in the proper type (Long/String) for the respective entity
The text was updated successfully, but these errors were encountered:
OmarHawk
changed the title
Javers integration not working properly for Entities Long IDs
Javers integration not working properly for Entities with Long IDs
Apr 4, 2024
Hi,
For Entities with Long IDs this view does not work after restarting the application (empty Javers cache) and already having these entries in database:
It creates a request that produces an internal server error (500)
It took me quite some time to figure out the root cause for this issue and it has something to do with how Javers processes IDs and stores these in the
jv_global_id
table and then how it processes request for data in that table and how this blueprint makes use of that.As you can see here, String IDs (like UUIDs) are quoted within the database table. Long ones are not quoted. That is happening completely in the background, i.e. nothing, the blueprint here can influence.
The problem is now with requests for showing changelog details.
The method is this one:
generator-jhipster-entity-audit/generators/spring-boot-javers/templates/src/main/java/_package_/web/rest/JaversEntityAuditResource.java.ejs
Lines 101 to 124 in c354ea7
This one gets entityId as a String type, no matter, what the original entity's ID type was and passes that String on to Javers. Javers in turn passes this Object type further on, and converts it somehwhere internally to a JSON String to pass that further on into a prepared statement. So to the prepared statement, also Long / String is being passed for execution, which also contains the mentioned quotes in the String case, but since we do pass everything as String, also for the Long-ID type entities. A query log demonstrates the problem:
The red one is the query for a Long-ID based entity, while the geen one is the UUID-ID (String) based entity:
Therefore, nothing is being found and we run into an java.lang.IndexOutOfBoundsException on this line in the get(0):
generator-jhipster-entity-audit/generators/spring-boot-javers/templates/src/main/java/_package_/web/rest/JaversEntityAuditResource.java.ejs
Line 120 in c354ea7
(!) Please note in can only be reproduced when clearing the Javers internal cache for Global IDs to enforce loading it from database, by i.e. restarting the application. The internal cache itself is sort of resistent against this issue.
Possible solution: Pass in the ID in the proper type (Long/String) for the respective entity
The text was updated successfully, but these errors were encountered: