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
Great library, we have just started using it and it works like a charm so far! Thank you for your continued effort.
I've just spend a while figuring out why I wasn't able to read data from the database as there was no exception and everything seemed to have worked. The issue turned out to be that there needs to be a default constructor for the mapping class, i.e. the class we wish to populate the values from the database with.
Long story short:
in com.datastax.driver.mapping.builder.MappingBuilder.getFromRow(Class<T>, Row):533 where you create a new instance based on the class object of the entity one wishes to map values to
if there is no default constructor of the entity, the entity reference will remain null. The javadoc also mentions this: Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. Hence, this does not lead to an exception when we set the database values in the following for-loop
Thanks for comments, this is a valid concern.
I initially started project with the minimum or no custom logging and error handling.
But as more and more people use it I should consider adding meaningful messages to it.
Thanks for the story, I am sorry I have to figure it hard way
Also, for those who might follow, if you don't have any constructor defined, Java adds the default constructor, which means this package will work (similar to all the test cases). Once you add your own, the default one is removed and this issue will occur.
Hey mate
Great library, we have just started using it and it works like a charm so far! Thank you for your continued effort.
I've just spend a while figuring out why I wasn't able to read data from the database as there was no exception and everything seemed to have worked. The issue turned out to be that there needs to be a default constructor for the mapping class, i.e. the class we wish to populate the values from the database with.
Long story short:
in
com.datastax.driver.mapping.builder.MappingBuilder.getFromRow(Class<T>, Row):533
where you create a new instance based on the class object of the entity one wishes to map values toif there is no default constructor of the entity, the
entity
reference will remain null. The javadoc also mentions this: Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. Hence, thisdoes not
lead to an exception when we set the database values in the following for-loopSuggestion:
In case a default constructor is absent, maybe throw an exception or log a statement so the user has a better idea what is going on?
The text was updated successfully, but these errors were encountered: