I am trying to use ORMLite to save a database in an Android project. This is clearly seen from the examples. As soon as I start using it, I find that I do not quite understand its requirements and behavior.
Let's say I have a class called Bone that I would like to keep.
@DatabaseTable(tableName = "bones") public class Bone{ // user defined @DatabaseField(dataType = DataType.STRING) private String color; @DatabaseField private double length; @DatabaseField private int quantity; // db assigned @DatabaseField(generatedId = true) private int id; public Bone(){ } // constructors public Bone(String color, int quantity) { this(color, quantity, 0); } public Bone(String color, int quantity, int id) { this.color = color; this.quantity = quantity; this.id = id; } public Bone(Bone old, int id){ this.color = old.color; this.length = old.length; this.quantity = old.quantity; this.id = id; } public String getColor() { return color; } public double getLength() { return length; } public int getQuantity() { return quantity; } public void setLength(double length) { this.length = length; } public int getId() { return id; } }
What are the requirements for the names of getters and setters of its fields? Do their names have no meaning? Can I use one without getter and setter?
Besides arg constructor, do you need any other constructor?
Please, help.
source share