Skip to content

Commit b8eb013

Browse files
committed
update insert
1 parent b2907ad commit b8eb013

4 files changed

Lines changed: 9 additions & 101 deletions

File tree

app/src/main/java/br/com/sql/Categoria.java

Lines changed: 0 additions & 84 deletions
This file was deleted.

app/src/main/java/br/com/sql/Example.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,10 @@ protected void onCreate(Bundle savedInstanceState) {
1616
super.onCreate(savedInstanceState);
1717
setContentView(R.layout.activity_example);
1818
SimpleSQL simpleSQL = new SimpleSQL(new HelperBD(this));
19-
// Pessoa pessoa = new Pessoa();
20-
// pessoa.setName("paulo");
21-
// simpleSQL.insert(pessoa).execute();
22-
//
23-
Categoria categoria = new Categoria();
24-
categoria.setIdCnpj(999999999);
25-
categoria.setNome("Teste");
26-
categoria.setImg(new byte[]{21,31,31});
27-
categoria.setValor(1f);
28-
categoria.setValue((short) 100);
29-
simpleSQL.insert(categoria).execute();
19+
Pessoa pessoa = new Pessoa();
20+
pessoa.setName("paulo");
21+
simpleSQL.insert(pessoa).execute();
22+
3023

3124

3225
List<Pessoa> list = simpleSQL.selectTable(new Pessoa())

app/src/main/java/br/com/sql/HelperBD.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
public class HelperBD extends SQLiteOpenHelper {
1818
private static final String NAME = "nome_banco.bd";
19-
private static final int VERSION = 13;
19+
private static final int VERSION = 14;
2020
private SimpleSQL simpleSQL;
2121

2222
public HelperBD(@Nullable Context context) {

simplesql/src/main/java/com/simplesql/simplesql/config/SimpleSQL.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ public String create(Object obj, SQLiteDatabase db) {
465465
/**
466466
* Developed by Paulo Iury
467467
* Method INSERT
468+
*
468469
*/
469470
public class Insert {
470471
private Object obj;
@@ -490,15 +491,13 @@ public boolean execute() {
490491
// Se o atributo tem a anotação
491492
Column column = field.getAnnotation(Column.class);
492493
if (column != null) {
493-
if (!field.isAnnotationPresent(AutoIncrement.class) && field.get(obj) != null) {
494+
if (!field.isAnnotationPresent(AutoIncrement.class) && field.get(obj) != null)
494495
checkObject(field, obj);
495-
}
496-
} else {
496+
} else
497497
throw new SQLException("The " + field.getName() + "attribute did not have the column annotation");
498-
}
499498
}
500499
long result = write.insert(obj.getClass().getSimpleName(), null, values);
501-
return result != -1;
500+
return result > -1;
502501
} else
503502
throw new SQLException("This class does not have the table annotation");
504503
} catch (SQLException e) {

0 commit comments

Comments
 (0)