-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
Can not set static final field #2607
Comments
I've worked around the problem by copying the FieldMapper class to jdbi-orm and patching it to ignore static fields; that works very well. A proper solution would probably add a line to FieldMapper.createSpecializedRowMapper() and would call a new |
Thanks for reporting this. I think we should filter out static fields by default. |
A fix for this issue (ignore all static fields) should be in the next release. |
Awesome, thank you so much for such a quick fix; and super-thanks for such an awesome library 👍 |
If the select returns a column with the same name as a public static final field in the bean, JDBI will try to write the value to that column and will fail with:
In the example above, I have a
SELECT x as department_name from y
mapping values to a bean with apublic static final String DEPARTMENT_NAME = "foo";
field viaFieldMapper
.Reasoning: in jdbi-orm I'm recommending the users to create a
public static final Property<> ID
fields which allows you to programmatically create Conditions such asPerson.ID.lt(25)
. However, since there is a database column named ID, JDBI's FieldMapper tries to write the value both to the instance fieldid
and the static final fieldID
and fails.I believe that JDBI should ignore static fields in general, or at least static final fields.
Meanwhile, is there a workaround/configuration which would allow me to ignore such fields please?
JDBI 3.43.0
The text was updated successfully, but these errors were encountered: