我试图链接/工作以下四个类之间的关系,作为ormlite数据库的表,
此类课程
@DatabaseTable(tableName = "item")
public class Item implements Serializable {
@SerializedName("kind")
@Expose
@DatabaseField
private String kind;
@SerializedName("id")
@Expose
@DatabaseField
private String id;
@SerializedName("blog")
@Expose
@DatabaseField (foreign = true, foreignAutoRefresh = true)
private Blog blog;
@SerializedName("published")
@Expose
@DatabaseField
private String published;
@SerializedName("updated")
@Expose
@DatabaseField
private String updated;
@SerializedName("etag")
@Expose
@DatabaseField
private String etag;
@SerializedName("url")
@Expose
@DatabaseField
private String url;
@SerializedName("selfLink")
@Expose
@DatabaseField
private String selfLink;
@SerializedName("title")
@Expose
@DatabaseField
private String title;
@SerializedName("content")
@Expose
@DatabaseField
private String content;
@SerializedName("author")
@Expose
@DatabaseField (foreign = true, foreignAutoRefresh = true)
private Author author;
@SerializedName("replies")
@Expose
@DatabaseField (foreign = true, foreignAutoRefresh = true)
private Replies replies;
@SerializedName("labels")
@Expose
@DatabaseField(persisterClass = ArrayPersister.class)
private String[] labels = null;
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Blog getBlog() {
return blog;
}
public void setBlog(Blog blog) {
this.blog = blog;
}
public String getPublished() {
return published;
}
public void setPublished(String published) {
this.published = published;
}
public String getUpdated() {
return updated;
}
public void setUpdated(String updated) {
this.updated = updated;
}
public String getEtag() {
return etag;
}
public void setEtag(String etag) {
this.etag = etag;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getSelfLink() {
return selfLink;
}
public void setSelfLink(String selfLink) {
this.selfLink = selfLink;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Author getAuthor() {
return author;
}
public void setAuthor(Author author) {
this.author = author;
}
public Replies getReplies() {
return replies;
}
public void setReplies(Replies replies) {
this.replies = replies;
}
public String[] getLabels() {
return labels;
}
public void setLabels(String[] labels) {
this.labels = labels;
}
}
博客类别
@DatabaseTable(tableName = "blog")
public class Blog implements Serializable {
@SerializedName("id")
@Expose
@DatabaseField(generatedId = true)
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
作者类
@DatabaseTable(tableName = "author")
public class Author implements Serializable {
@SerializedName("id")
@Expose
@DatabaseField
private String id;
@SerializedName("displayName")
@Expose
@DatabaseField
private String displayName;
@SerializedName("url")
@Expose
@DatabaseField
private String url;
@SerializedName("image")
@Expose
@DatabaseField(dataType = DataType.SERIALIZABLE)
private Image image;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Image getImage() {
return image;
}
public void setImage(Image image) {
this.image = image;
}
}
回复课程
@DatabaseTable(tableName = "replies")
public class Replies implements Serializable {
@SerializedName("totalItems")
@Expose
@DatabaseField
private String totalItems;
@SerializedName("selfLink")
@Expose
@DatabaseField
private String selfLink;
public String getTotalItems() {
return totalItems;
}
public void setTotalItems(String totalItems) {
this.totalItems = totalItems;
}
public String getSelfLink() {
return selfLink;
}
public void setSelfLink(String selfLink) {
this.selfLink = selfLink;
}
}
项包含Blog,Author,Replies,这三个类是问题的主题,因为我必须在它们和item类之间建立关系。我面临的第一个问题是在四个类中所有id的字段都定义为“ String”,并且主键或外键当然不能定义为字符串,我试图将其转换为整数,但是从服务器获取的id就像"2632206540636403989"
,"6707328668304971444"
对于整数太大