ORM Lightweight Framework: Activeandroid overview

Source: Internet
Author: User
Tags table name

ORM is object-relational Mapping, Object Relational mapping. A simple understanding is to map our Java objects to the records in the database, to persist the entity objects to the database, and to map the records of queries to Java objects. ORM frees us up, and there's no need to write long, obscure SQL statements, everything is done through frameworks, and it's a great boon to programmers.

The principle of ORM framework implementation is also very simple, that is, the use of Java reflection mechanism of the object and Database Record Mapping Association. For example, when storing, the object's attributes are taken out as the attribute value of the record, and the query is automatically constructed into a SQL statement, and the result set of the query is converted into a list of objects. Java EE has a ibatis,hibernate framework, we have Android greendao,ormlite,xutils,afinal and so on. They all work the same way, and the difference is in detail. If the interest of the classmate, recommended reading under the activeandroid source. Reading the fucking code!

Previously wrote a series of articles about Xutils, the Finaldb module is an ORM framework, which is also used in my work. The Activeandroid API we are introducing today is also quite simple and friendly and powerful. Activeandroid Concise API gives people a feeling that it is comfortable to use, and today is mainly about the simple use of crud.

First, initialization

There are two ways, one is to configure the application Name property of the Androidmanifest, and optionally configure the name and version of DB in the Meta-data tab The second is to inherit the application of activeandroid in its own application class, the first two ways are too intrusive, and there is a static injection of two methods in a custom application.

Ii. Defining entity Classes

Entity classes need to inherit model to customize the name of the field corresponding to the table name and attribute

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

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.