Fixed an issue where Android Greendao has no default value and no original data type

Source: Internet
Author: User

Most Android app development siege Lions have heard and worked effectively on Greendao, making it stand out among the many ORM tools.

Recently there is a project for the efficiency of SQLite, so it is quite, but in the middle encountered two problems title said

1. there is no corresponding API in the Greendao Generator project to set the default value, for example:

Entity.addintproperty ("Test"). Defvalue ("7");

2.greenDAO Generator the Java entity class and the DAO class used in the reference data type, such as: int->integer,long->long and so on, with this there is a problem, the caller plugs into the Integer, That is the risk of being null.

Check the information, Google, found Greendao disdain to achieve two functions, no way, wasted a long time to modify the source code, hit a jar package of their own projects with, share

The main changes in the Daogenerator project in the PROPERTY.JAVA,ENTITY.FTL,DAO.FTL these three files.

Once modified, you can use this:

    //Test    Private Static voidaddnote (schema Schema) {Entity Note= Schema.addentity ("Note");        Note.addidproperty (); Note.addstringproperty ("Text"). Notnull (). Defvalue ("\" y\ ""); Note.addstringproperty ("Comment"); Note.addstringproperty ("Test"); Note.addintproperty ("Test3"). Primjavatype (). Defvalue ("7"); Note.addintproperty ("Test4"); Note.adddateproperty ("Date"); }

Hit the jar, not uploaded, who have to leave the mailbox, I passed him.

Fixed an issue where Android Greendao has no default value and no original data type

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.