casidiablo / persistence

Android persistence library
http://casidiablo.github.io/persistence
74 stars 20 forks source link

How are column names determined? #10

Open bkjbkjbnkj687698698 opened 9 years ago

bkjbkjbnkj687698698 commented 9 years ago

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 "
casidiablo commented 9 years ago

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

bkjbkjbnkj687698698 commented 9 years ago

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

razorblade446 commented 9 years ago

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: notifications@github.com To: persistence@noreply.github.com 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.

casidiablo commented 9 years ago

@bhuvneshvarma There are examples in the README