我有ActiveAndroid模型,
public class Workbook extends Model {
@Expose
@Column(name = "WorkbookID",unique = true, onUniqueConflict = Column.ConflictAction.REPLACE)
private Integer ID;
@Expose
@Column(name = "UserID")
private Integer UserID;
@Expose
@Column(name = "Name")
private String Name;
@Expose
@Column(name = "Descript")
private String Descript;
@Expose
@Column(name = "CategoryID")
private Integer CategoryID;
@Expose
@Column(name = "TotalQuestions")
private Integer TotalQuestions;
@Expose
@Column(name = "TotalCorrect")
private Integer TotalCorrect;
@Expose
@Column(name = "TotalInCorrect")
private Integer TotalInCorrect;
@Expose
@Column(name = "IsCompleted")
private Boolean IsCompleted=false;
public Workbook(){
super();
}
}
此注释将“onUniqueConflict = Column.ConflictAction.REPLACE”替换发现冲突的整行。但我想要做的是更改特定列值,其余列值应保持不变。 如INSERT OR REPLACE那样。 在我的情况下,只想更改列(UserID,Name,Descript,CategoryID,TotalQuestions)和列的其余部分(TotalCorrect,TotalInCorrect,IsCompleted)值保持不变。
任何人都知道如何使用Active Android实现这一目标吗?
提前致谢:)
答案 0 :(得分:1)
我已经尝试了很多,但它是消极的。最后,我接近,否则条件插入或替换在一起。可能是我的回答对于想要做这种操作的人有用。这是棘手的,更糟糕的解决方案。
if(condition)
//do stuff for insertion operation
else
//do stuff related to update