Android ORMapping Library

Source: Internet
Author: User

Android ORMapping Library
I used Java annotations to implement the Android SQLite ORM library. I have written XML before. However, I feel that it is not very stable and the efficiency and robustness are not good in all aspects, it took me one afternoon to complete all the annotations and comments, generate javadoc, write the sample program, and publish it to Github: duplicate copy code 1 // entity class 2 @ Table (name = "dog") 3 public class Dog {4 private boolean alive; 5 private int id; 6 private String name; 7 8 public Dog () {9 10} 11 12 public Dog (boolean alive, String name) {13 this. alive = alive; 14 this. name = name; 15} 16 17 @ Id (name = "id") 18 @ Column (name = "id", type = DataType. integer) 19 public int getId () {20 return id; 21} 22 23 @ Column (name = "name", type = DataType. varchar, length = 20) 24 public String getName () {25 return name; 26} 27 28 @ Column (name = "alive", type = DataType. boolean) 29 public boolean isAlive () {30 return alive; 31} 32 33 public void setAlive (boolean alive) {34 this. alive = alive; 35} 36 37 public void setId (int id) {38 this. id = id; 39} 40 41 public void setName (String name) {42 this. name = name; 43} 44} 45 46 // Add 47 AnnotationDao = new AnnotationDao (this, Dog. class); 48 49 String name = "dog1"; 50 boolean alive = true; 51 52 Dog dog = new Dog (alive, name); 53 dao. insert (dog); 54 55 // search 56 // List all objects 57 list = dao. list (); 58 // query 59 dao by ID. query (3); 60 61 // Delete 62 dao. delete (dog); 63 64 // update. When updating, ensure that the id field corresponds to the value in the database, that is, the 65 dog obtained by calling list or query. setName ("dog2"); 66 dao. update (dog );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.