2015-07-31 18 views
5

Tôi muốn ánh xạ chuyển đổi sang lớp này và ghi vào cơ sở dữ liệu bằng cách sử dụng "ActiveAndroid". Tôi không biết tôi nên đặt loại chú giải nào ?. tổ chứcId phải là duy nhất. Tôi có nên viết một số phương pháp cho truy vấn chọn không ?.Chú thích ActiveAndroid ORM

public class Organization extends Model { 

    private String organizationId; 

    private List<Doctor> doctors; 

    private String organizationName; 

    private String photoUrl; 

    private Address address; 

    private Set<String> phoneNumber; 

    private String faxNumber; 

    private String key; 

    private int numberOfDoctors; 
} 
+0

Bạn đã đọc tài liệu ActiveAndroid chưa? Tôi nghĩ điều đó sẽ cho bạn biết chú thích nào cần sử dụng. – nasch

Trả lời

0

cho đơn giản sử dụng cột @column chú thích như:

@Column(name="org_name") 
private String organizationName; 

và độc đáo hạn sử dụng

@Column(name="org_id" , unique = true , onUniqueConflict = Column.ConflictAction.IGNORE) 
private String organizationId; 

và đừng quên đặt bảng chú thích cho lớp

@Table(name = "organization") 
public class Organization extends Model {