hazelcast icon indicating copy to clipboard operation
hazelcast copied to clipboard

SQL UPDATE unusable on objects with read-only fields

Open viliam-durina opened this issue 4 years ago • 0 comments

Let's say we have a class:

class Person {
    public String name;
    private LocalDate birthDate;

    public int setBirthYear() {
        return birthDate.getYear();
    }
}

And we have an IMap<Long, Person>. Then this query will fail:

UPDATE person_map SET name='foo' WHERE __key='10'

The exception is:

Cannot set property "birthYear" to class com.example.Person: no set-method or public field available

However, we expect this (or similar) exception to be thrown if the birthYear field is actually listed in the SET clause.

We should be able to work with classes with read-only derived fields.

Note: it's not required to fix the use case when the read-only property is actually backed by a field, just the setter for some reason isn't public (e.g. it's package-private). The UPDATE implementation doesn't just set the value to existing java instance, but it creates a new instance and sets all the fields. But if we're able to actually set value in existing instance, that would be even better.

viliam-durina avatar Nov 12 '21 08:11 viliam-durina