How to update column with ORMLite How to update column with ORMLite sqlite sqlite

How to update column with ORMLite


I want to update catType on the basis of catId. How can I update this catType column with the catId in ORMLite.

ORMLite also supports an UpdateBuilder. Here's how you could use it:

UpdateBuilder<Category, Integer> updateBuilder = catDao.updateBuilder();// set the criteria like you would a QueryBuilderupdateBuilder.where().eq("categoryId", 5);// update the value of your field(s)updateBuilder.updateColumnValue("catType" /* column */, "BarType" /* value */);updateBuilder.update();

See the UpdateBuilder docs for more examples.


Dao<Category, Integer> catDao = getHelper().getCategoryDao();List <Category> categoryList = catDao.queryForAll();for (Category c: categoryList ) {    c.setCategoryType("BarType");    catDao.update(c);}