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
Cassandra list/set typed columns represent an empty collection as null. From here one can't tell whether the state was null or empty at the time saving the value. Loading this value causes MappingCassandraConverter to overwrite pre-initialized fields (e.g. with new ArrayList) with null.
There is also the option of handling the null in a constructor that Spring Data uses to instantiate the model. The reference guide actually recommends using an all argument constructor, and if you make the model immutable (also a recommendation), there's no need to also provide a setter.
A constructor approach does require a bit more care, so it's important to fully understand the requirements documented in the reference guide (see the "Object Mapping Fundamentals" section), and you can't simply rely on Lombok's @AllArgsConstructor, which makes the property access approach a bit simpler in terms of implementation/maintenance
Mark Paluch opened DATACASS-266 and commented
Cassandra list/set typed columns represent an empty collection as
null
. From here one can't tell whether the state wasnull
or empty at the time saving the value. Loading this value causesMappingCassandraConverter
to overwrite pre-initialized fields (e.g. withnew ArrayList
) withnull
.Affects: 1.3.4 (Gosling SR4)
Reference URL: http://stackoverflow.com/questions/36349896/how-can-i-ensure-cassandraoperations-selectonebyid-initializes-all-fields-in-t
1 votes, 4 watchers
The text was updated successfully, but these errors were encountered: