Connection is read-only. Queries leading to data modification are not allowed
I peeked at the code. In fact it is doing something illegal. The code in FormFilterServiceImpl:75 in fact creates a new form filter object and then returns it. But this line of code declares it should be in a read-only transaction. So the code is incorrect, and Hibernate is correct to throw this error.
It seems this was added in this commit, from 2012, but the commit message does not say why this is done.
@ningosi, can you comment on how eSaude is using this module? E.g. are you purely configuring it via the API or something, thus you don’t hit this bug in the UI?
Version 1.0.0 just run fine of 1.11.5 and after filtering forms via such, I am able to click on it and it loads properly. We just use the module on the patient dashboard. See the attached for review and clicking on one loads without errors
@mozzy I think the correct approach here would be to Branch off at the last known good release, and make a release like 1.0.1 that supports platform 2.x.
I had made a suggestion just from reading Nicholas’s comment, but now that I peek at the code I don’t think it will work.
@ningosi the offending code is present in the 1.0.0 tag also. Can you verify if this works after you create a new form, and click on it the first time?
(@mozzy what are your steps to reproduce this error? between creating a form, installing the module, etc, what order do you do things?)
the module installs succesfully, and starts succesfully, but when i click on
“manage Form Filtering” and i try to select a form, then it throws the error
I just created an html form in 1.11.5 running 1.0 version of form filter and clicked on it, filled the observations and saved successfully. Let me try testing @mozzy PR in 2.x and see what happens
Testing platform version 2.0.5, form filter module version 1.2(I checked out that tag from master)
The module loaded and started successfully. When I click on Manage Form Filtering, the list of forms appears, When I click on any one of the available form I get error as you reported. When I load the patient dashboard(having patient context) and click on Form Entry tab am able to load the form without errors(That has been our use case)
I think it makes sense for the second results in that every form should be filled for a patient, or before filling a form, one should be in a patient context. I maybe wrong maybe that module intention was to fit in both settings, please correct me @darius. Maybe this module do not need that extension point on the UI, or on clicking on it, one must be forced to select a patient.
@mozzy there are several possible approaches here (going from worst to best)
Say that “it was already broken in the UI, but it works for @ningosi in their use case, so this is good enough” so just release this as-is
Do the quickest hack to make the code work (remove read-only from here)
Explore the code, understand what it’s currently trying to do, and then refactor it so that (a) getFormFilter(Form) is read-only, (b) but it otherwise behaves as intended. I presume this means moving the “create new FormFilter object for a Form” logic from the service into the web controller.
Even #1 is “good enough” at a basic level; it depends on how much time you have to look into this.