i'm used kotlin, and i got some error when i try to get data with sugarORM
D/SQL Log: SQLiteQuery: SELECT * FROM PRODUCT_SUGAR_ORM W/System.err: java.lang.NoSuchMethodException: <init> []
at java.lang.Class.getConstructor(Class.java:531)
at java.lang.Class.getDeclaredConstructor(Class.java:510)
at com.orm.SugarRecord.getEntitiesFromCursor(SugarRecord.java:212)
at com.orm.SugarRecord.find(SugarRecord.java:204)
at com.orm.SugarRecord.listAll(SugarRecord.java:127)
and this is my code
data class ProductSugarORM(
var base_price: Double,
var category: Int,
val created_on: String,
var description: String,
val id: Int,
var name: String,
var sell_price: Double,
var stock: Int,
val store: Int,
val type: String,
val updated_on: String
):SugarRecord(){
fun ProductSugarORM(){}
}
i want to see the result using Log.w("load-local", "${SugarRecord.listAll(ProductSugarORM::class.java)}")
Note in the documentation that your implementations need an empty constructor. You will need to add an empty constructor. That would mean adding default values for all these parameters, which may not make sense.
I'm not sure you can get away with a data class anyway, because they are immutable, and it seems Sugar is using some reflection behind the scenes which might need mutability (don't know).