persistence icon indicating copy to clipboard operation
persistence copied to clipboard

How are column names determined?

Open bkjbkjbnkj687698698 opened this issue 10 years ago • 4 comments

i am having issues using Contraints.If i don't use contraints data loads perfectly.But if i try running following query-

Constraint constraint = new Constraint().orderBy("noOfSeen");
List cached = adapter.findAll(database,constraint);

where noOfSeen is the variable of object class.I assumed that the table in [persistence][2] creates column name according to the variable name in object class. but i get following exception

android.database.sqlite.SQLiteException: no such column: noOfSeen (code 1): , while compiling: SELECT * FROM videos ORDER BY noOfSeen

How are column names determined while creating table through this wrapper.How can i use following query of normal database in this wrapper?

"SELECT  * FROM " + TABLE_VIDEO +" where " + KEY_TYPE + "='popular'"+ " order by " + KEY_NOSEEN + " DESC "

bkjbkjbnkj687698698 avatar Mar 11 '15 14:03 bkjbkjbnkj687698698

The column should be snake case: no_of_seen. You can control that by using annotations in the pojo fields.

casidiablo avatar Mar 11 '15 18:03 casidiablo

Are the column names according to the variables used in object classes..and how can we execute where clauses using this library?

bkjbkjbnkj687698698 avatar Mar 11 '15 19:03 bkjbkjbnkj687698698

The column names are camelized counterparts of the variables, so:

NoOfSeen (POJO) -> no_of_seen (SQLite)

Frederic Yesid Peña Sánchez Web Developer - Designer PHP - MySQL advanced Programmer Tigo proud user IVR

Date: Wed, 11 Mar 2015 12:24:52 -0700 From: [email protected] To: [email protected] Subject: Re: [persistence] How are column names determined? (#10)

Are the column names according to the variables used in object classes..and how can we execute where clauses using this library?

— Reply to this email directly or view it on GitHub.

razorblade446 avatar Mar 11 '15 20:03 razorblade446

@bhuvneshvarma There are examples in the README

casidiablo avatar Mar 12 '15 00:03 casidiablo