Annotate the created greenDao object

I see that greenDao prefers not to use annotations to generate DAO and TO due to performance issues. However, what if I still need to comment, for example, TO for parser purposes? Is there any way to achieve this?

Example:

If we create a Customer object with code generation GreenDAO, it will create the classes CustomerDAO and Customer, right?

So, what if I use SOAP web services that return a Customer object, and to facilitate parsing this Customer object, I use an annotated structure such as simpleXML. Is there a way to change the Customer class without losing every annotation when regenerating code using GreenDAO?

Thanks!

+4
source share
2 answers

You can try using our fork on the way, which adds support for annotations. (he also adds support for enumeration and serialization) https://github.com/path/greenDAO is on my plate to send a stretch request, but not sure when I will have time.

btw, our version is not very well tested as greenDAO, but we used it in production for a while, so it should be fairly stable.

To add annotations, you can check out this code example: https://github.com/path/greenDAO/blob/master/DaoExampleGenerator/src/de/greenrobot/daogenerator/gentest/ExampleDaoGenerator.java#L42

btw, our fork creates two classes for each entity object. EntityBase , which is abstract and includes all fields, etc. And Entity , which extends EntityBase . You must edit Entity .

+5
source

You can add annotations with greendao 2.0 like this

 entity.addStringProperty("title").codeBeforeField("@com.google.gson.annotations.SerializedName( \"title\" )"); 
+9
source

All Articles