Closed techievbv closed 4 years ago
I could not find any documentation on Room clearly stating such a naming is banned but the following must be reason.
From Room documentation:
If you use getter and setter methods, keep in mind that they're based on JavaBeans conventions in Room.
In section 8.3.2 of JavaBeans documentation boolean properties naming convention is stated as:
public boolean is<PropertyName>();
e.g public boolean isMarsupial();
So, I guess Room does not expect a field name which starts with 'is' . That will be confusing for generated Room database code since it will try to access the unwrapped property name starting with 'is'.
This doesn't seem to be an issue with the samples. You can file an issue against Room on the issue tracker if you're still having an issue.
Hi everyone,
I am enjoying using Room library to have robust access to my Android app's SQlite database. But, today I discovered a weird issue while creating new Columns into the database, that I thought of sharing to everyone here.
So, I added a new column into one of my tables and named the column property as "isSuspend" of Boolean type. But, I noticed the app started crashing as soon as it launched.
Everything seemed good, I updated the db version as well, tried uninstalling and reinstalling the app, but the app kept crashing for virtually no reason as I checked the logcat.
Hence, after some minutes of Google search , I randomly changed the name from "isSuspend" to "suspend" and Voila!! it worked.
@ColumnInfo(name = "isSuspend") (doesn't work, crashes) @ColumnInfo(name = "suspend") (works)
Another issue that occurs due to this naming convention is, when that same column property "isSuspend" is of type Int, String or Long , the Build would fail with the error : "Cannot find setter for the property isSuspend" and unless you remove the "IS" from the name, the build would keep on failing.
The sad part is, this naming convention restriction is not mentioned anywhere in Room's android documentation. Also, curious to know what might be the reason for the same.