Skip to content Skip to sidebar Skip to footer

Do I Need Getters And Setters And Extra Entity Constructors?

I am trying to use ORMLite for database persistence in Android project. It looks all good from examples. Once I start to use it, I found I do not completely understand its requirem

Solution 1:

1) What are the requirements for the names of getters and setters of its fields? Does their names make any difference? Can I use one without getter and setter?

There are no requirements for getters and setters. By default ORMLite uses reflection to build the entity fields directly.

If you set the useGetSet = true field of the @DatabaseField annotation then you do neet get/set methods. See the javadocs for the format.

2) Besides no arg constructor, any other constructor is needed?

No. You only need an accessible no-arg constructor for ORMLite to instantiate the object prior to the reflection work.

Post a Comment for "Do I Need Getters And Setters And Extra Entity Constructors?"