Android 프로젝트에서 데이터베이스 지속성을 위해 ORMLite를 사용하려고합니다. 모든 예제에서 좋은 것처럼 보입니다. 일단 내가 그것을 사용하기 시작하면, 나는 그것의 요구와 행동을 완전히 이해하지 못한다는 것을 발견했다.게터와 세터 및 추가 엔티티 생성자가 필요합니까?
의 나는 내가 계속하고 싶은 뼈라는 클래스가 있다고 가정 해 봅시다.
@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;
}
}
해당 필드의 getter 및 setter의 이름에 대한 요구 사항은 무엇입니까? 이름이 다른가요? getter 및 setter없이 하나를 사용할 수 있습니까? 어떤 인수 생성자 게다가
- 는 다른 생성자가 필요하다?
도와주세요.
있습니까? – deviant
그 질문을하고 사용자 목록 @deviant에 대한 자세한 내용을 제공 할 수 있습니까? https://groups.google.com/forum/#!forum/ormlite-user – Gray
내가 인수 없음의 생성자를 두지 않았다 그러나 그것은 작동합니다. 왜? –