3434import java .util .Arrays ;
3535import java .util .Comparator ;
3636import java .util .List ;
37+ import java .util .Locale ;
3738
3839
3940/**
@@ -116,7 +117,7 @@ private void prepareCreateTablesQueryStr() {
116117 int index = 0 ;
117118 for (ColumnModel tableColumnModel : databaseTable .columnModels ) {
118119 index ++;
119- query += tableColumnModel .name + " " + SQLiteTypes . findType (tableColumnModel .datatype );
120+ query += tableColumnModel .name + " " + new SQLiteJavaTypes (). getSQLiteType (tableColumnModel .datatype );
120121 if (tableColumnModel .hasInlineConstraint ) {
121122 for (ConstraintModel constraint : tableColumnModel .constraintModels ) {
122123 query += " " + constraint .getConstraintKeyword ();
@@ -195,7 +196,7 @@ public int compare(Field field, Field t1) {
195196 if (!((Column ) columnName ).value ().equals (columnDefaultValue )) {
196197 columnAnnotationModel .columnName = ((Column ) columnName ).value ();
197198 }
198- String simpleNameOfDataType = (foreignKey != null ) ? SQLiteTypes . INTEGER_NULLABLE . getJavaType () : column .getType ().getSimpleName ();
199+ String simpleNameOfDataType = (foreignKey != null ) ? "Integer" : column .getType ().getSimpleName ();
199200 currentColumnModel = new ColumnModel (columnAnnotationModel .columnName , simpleNameOfDataType );
200201 currentColumnModel .hasInlineConstraint = false ;
201202
@@ -259,7 +260,7 @@ public int compare(Field field, Field t1) {
259260 prepareCreateTablesQueryStr ();
260261 }
261262
262- public <T extends Tableable > long insert (T tableModel ) {
263+ static <T extends Tableable > long insert (T tableModel ) {
263264 String name = Utils .getTableName (tableModel .getClass ());
264265
265266 ContentValues contentValues = new ContentValues ();
@@ -280,7 +281,7 @@ public int compare(Field field, Field t1) {
280281 boolean isForeignKey = field .isAnnotationPresent (ForeignKey .class );
281282
282283 String simpleNameOfDataType = (isForeignKey )
283- ? SQLiteTypes . INTEGER_NULLABLE . getJavaType () : field .getType ().getSimpleName ();
284+ ? "Integer" : field .getType ().getSimpleName ();
284285
285286 try {
286287 //Todo: Look up for default functionality in integers. It does not work
@@ -703,7 +704,7 @@ public Builder setWillBeUpdated(boolean willBeUpdated) {
703704 }
704705
705706
706- private static <T extends Tableable > int update (T tableModel ) {
707+ static <T extends Tableable > int update (T tableModel ) {
707708 SQLiteDatabase writable = sqLiteManager .getWritableDatabase ();
708709 String whereClause = null ;
709710 String [] whereArgs = null ;
@@ -719,7 +720,9 @@ private static <T extends Tableable> int update(T tableModel) {
719720 try {
720721 if (field .isAnnotationPresent (PrimaryKey .class )) {
721722 whereClause = Utils .getMemberColumnName (field ) + "=?" ;
722- whereArgs = new String []{field .get (tableModel ).toString ()};
723+ int idValue = (int ) field .get (tableModel );
724+ if (idValue == 0 ) return -1 ;
725+ whereArgs = new String []{String .format (Locale .getDefault (), "%d" , idValue )};
723726 }
724727
725728 contentValues .put (colName , field .get (tableModel ).toString ());
0 commit comments