Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i achieve Insert or Replace column values with Active Android?

I have model of ActiveAndroid like,

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();
   }
  }

This annotation will "onUniqueConflict = Column.ConflictAction.REPLACE" replace entire row where conflict found.but what i suppose to do is change specific column value and rest of column values should remain unchanged. As INSERT OR REPLACE will do. In my case want to change only column (UserID, Name, Descript, CategoryID, TotalQuestions) and rest of column(TotalCorrect, TotalInCorrect, IsCompleted) value remains same it is.

Can any one know how to achieve this with Active Android?

Thanks in Advance :)

like image 523
Nidhi Avatar asked Jan 27 '26 00:01

Nidhi


1 Answers

I have tried a lot but its negative. finally i approached if else condition to insert or replace together. May be my answer will useful to who is want to do this kind to operation. it is tricky and worse solution.

   if(condition)
   //do stuff for insertion operation
   else
   //do stuff related to update
like image 122
Nidhi Avatar answered Jan 28 '26 16:01

Nidhi