kamikat / moshi-jsonapi

JSON API v1.0 Specification in Moshi.
MIT License
156 stars 34 forks source link

Possibly incompatible with Google's Room persistence library for Android? #68

Closed es0329 closed 6 years ago

es0329 commented 7 years ago

Room attempts to match a model's fields with valid SQLite data types. It will also disregard fields with an @Ignore annotation. Otherwise, a type converter must be supplied where type affinity cannot be made by the compiler.

My models subclass Resource and ResourceIdentifier in turn. I think without annotations or a type converter, those super class fields might trigger the following at compile time:

error: Cannot figure out how to save this field into database. You can consider adding a type converter for it.

I'm not certain of the issue so I continue trying to understand it but I wanted to share the issue.

kamikat commented 7 years ago

There's nothing to do with the library. To implement type converters for every data model is terrible but the only solution.

I opened the issue to see if it help.

es0329 commented 6 years ago

At the time of our inquiry, I moved forward by separating DTO and DAO. Now, @Ignore superclass fields released in Room v2.1.0-alpha01, looks a lot like what we requested. Not certain though, it may require subclassing Room's @Entity.

Separate models was appropriate for my case but I wanted to update our issue for future reference.