student = new Student(null, "李加", "男", 18, "四川", "abc");
//1、通过DaoMaster调用newDevSession创建DaoSession对象
DaoSession daoSession = DaoMaster.newDevSession(this, StudentDao.TABLENAME);
//2、获取对应的Dao对象
studentDao = daoSession.getStudentDao();
//3、调用增删改查的方法
studentDao.insert(student);//增
// List<Student> list = new ArrayList<>();
// for (int i = 0; i < 10; i++) {
// Student student = new Student(null, "李加" + i, "男", 18, "四川", "abc");
// list.add(student);
// }
// studentDao.insertInTx(list);
//添加多条
studentDao.update(student);//改
studentDao.delete(student);//删
studentDao.loadAll();//查询所有
//条件查询
//1、先获取QueryBulder对象
QueryBuilder<Student> builder = studentDao.queryBuilder();
//单个条件查询 gt > lt < ge >= le<= eq == like 模糊查询
builder.where(StudentDao.Properties.Id.gt(6)).build().list();
//and条件查询 多条件&查询
WhereCondition condition = builder.and(StudentDao.Properties.Id.gt(6), StudentDao.Properties.Address.eq("河北"));
builder.where(condition).build().list();//多条件查询
//or条件查询 多条件|查询
WhereCondition conditionOr = builder.or(StudentDao.Properties.Id.gt(6), StudentDao.Properties.Address.eq("河北"));
builder.where(conditionOr).build().list();//多条件或查询
//1、通过DaoMaster调用newDevSession创建DaoSession对象
DaoSession daoSession = DaoMaster.newDevSession(this, StudentDao.TABLENAME);
//2、获取对应的Dao对象
studentDao = daoSession.getStudentDao();
//3、调用增删改查的方法
studentDao.insert(student);//增
// List<Student> list = new ArrayList<>();
// for (int i = 0; i < 10; i++) {
// Student student = new Student(null, "李加" + i, "男", 18, "四川", "abc");
// list.add(student);
// }
// studentDao.insertInTx(list);
//添加多条
studentDao.update(student);//改
studentDao.delete(student);//删
studentDao.loadAll();//查询所有
//条件查询
//1、先获取QueryBulder对象
QueryBuilder<Student> builder = studentDao.queryBuilder();
//单个条件查询 gt > lt < ge >= le<= eq == like 模糊查询
builder.where(StudentDao.Properties.Id.gt(6)).build().list();
//and条件查询 多条件&查询
WhereCondition condition = builder.and(StudentDao.Properties.Id.gt(6), StudentDao.Properties.Address.eq("河北"));
builder.where(condition).build().list();//多条件查询
//or条件查询 多条件|查询
WhereCondition conditionOr = builder.or(StudentDao.Properties.Id.gt(6), StudentDao.Properties.Address.eq("河北"));
builder.where(conditionOr).build().list();//多条件或查询