-
Notifications
You must be signed in to change notification settings - Fork 788
DBLibrary
kymjs edited this page Nov 12, 2015
·
2 revisions
#DBLibrary Summary
DBLibrary come from afinal->finalDB
in android orm framework. Make use of sqlite handle. one line just to add/delete/update/query. holder one-more,more-one entity
// data file
KJDB db = KJDB.create(this);
User ugc = new User(); //warn: The ugc must have id field or @ID annotate
ugc.setEmail("[email protected]");
ugc.setName("kymjs");
db.save(ugc);
//one - many
public class Parent{ //JavaBean
private int id;
@OneToMany(manyColumn = "parentId")
private OneToManyLazyLoader<Parent ,Child> children;
/*....*/
}
public class Child{ //JavaBean
private int id;
private String text;
@ManyToOne(column = "parentId")
private Parent parent;
/*....*/
}
List<Parent> all = db.findAll(Parent.class);
for( Parent item : all){
if(item.getChildren ().getList().size()>0)
Toast.makeText(this,item.getText() + item.getChildren().getList().get(0).getText(),Toast.LENGTH_LONG).show();
}