Watch 2 Star 2 Fork 5

叶大侠 / AndroidGenericDaoJava

Sign up for free
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
Android通用DAO spread retract

Clone or download
Notice: Creating folder will generate an empty file .keep, because not support in Git

功能: (1):能够方便地创建表和对象的对应关系.[这里我们以注解的方式实现]



@Table(name = "t_user")
public class TUser {
    private Integer userId;
    private String userName;
     * 必须提供无参构造函数
    public TUser() {}
    public TUser(String userName) {
        this.userName = userName;

//Insert An Object
IBaseDao<TUser> userDao = DaoFactory.createGenericDao(this, TUser.class);
userDao.insert(new TUser("AAAA"));
//Insert Object List
List<TUser> insertUserList = new ArrayList<TUser>();
for(int i = 0; i<10;++i){
    insertUserList.add(new TUser("BBB"+i));
List<TUser> userList = userDao.queryByCondition("user_name=?", "AAAA");
userDao.insertOrUpdate(new TUser("AAAA"), "user_name"); //update where user_name='AAAA'
userDao.insertOrUpdate(new TUser("CCCC"), "user_name"); //insert CCCC

Comments ( 0 )

You need to Sign in for post a comment

Help Search