-
Notifications
You must be signed in to change notification settings - Fork 80
#292 - Error loading locations on OpenMRS 2.7 #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@ibacher / @Ruhanga - I was hoping to add @mogoodrich as a reviewer, but that does't seem allowed. Any way I can be able to add him in? I'd like to be able to get this fix in before too long, as this is currently the only thing blocking our ability to upgrade to 2.7.x. Feel free to loop in others to review as appropriate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, LGTM, and I trust it will work as expected at runtime. I do have a small comment below, though.
if (attributeType == null) { | ||
throw new IllegalArgumentException("An attribute value is specified ('" + attributeValueStr | ||
+ "') for an attribute type that cannot be resolved by the following identifier: '" | ||
+ attributeType + "'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this was meant to point to attributeTypeIdentifier
? Would be nice having a unit test covering this - maybe not strictly necessary?
+ attributeType + "'"); | |
+ attributeTypeIdentifier + "'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch @Ruhanga . I've updated that. This isn't new functionality, my main goal was to ensure all existing unit and integration tests pass, as well as any that I copied into the api-2.7 project, so my assumption is that the existing unit test coverage is sufficiently robust to handle a refactor.
Hi @mseaton, there seems to be failures when running with OpenMRS < 2.7.0 the following error is thrown, might you have seen this already? Example trace below...
|
@Ruhanga I have not seen anything like this. First question I'd have to ask is whether you have a Location Attribute with UUID of |
Ah, I see now. Thanks for highlighting this. It's probably that the attribute type ( |
This PR copies the existing LocationsLoaderIntegrationTest into the api-2.7 module to demonstrate that this test fails when run in an OpenMRS 2.7 environment.
The cause appears to be due to a change to Hibernate from v5 to v6, as well as a move from xml mapping files to JPA annotations, which is leading to slightly different behavior that previously. The particular error seems to stem from the way the BaseAttributeLineProcesser handles attributes - which is by removing any existing attributes from the collection and adding a new one in.
The change that has been implemented here changes this to the following:
This is a change to the previous behavior which always deleted old values, whether they had changed or not. This deletion was done by removing old values from the attributes collection on the object, rather than voiding the attributes in place. This seems to have been the root of the issue, as we were running into situations where Hibernate was trying to flush objects to the database that had been disconnected from their related objects (eg. trying to flush an update to a LocationAttribute that no longer was associated to a Location, thus trying to save null as the location_id column in the location_attribute table).
@rbuisson / @ibacher / @Ruhanga - FYI