New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got the below error , #38

Closed
nagendraksrivastava opened this Issue May 14, 2015 · 15 comments

Comments

Projects
None yet
2 participants
@nagendraksrivastava

nagendraksrivastava commented May 14, 2015

android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: rush_com_cc_dailyrounds_response_CaseListResponse_rush_com_cc_dailyrounds_response_User_details_user_details.rush_id (code 1555)
at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native Method)
at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:734)
at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1676)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1605)
at co.uk.rushorm.android.AndroidRushStatementRunner.runRaw(AndroidRushStatementRunner.java:37)
at co.uk.rushorm.core.RushCore$9.runRaw(RushCore.java:368)
at co.uk.rushorm.core.implementation.ReflectionUpgradeManager.moveRows(ReflectionUpgradeManager.java:284)
at co.uk.rushorm.core.implementation.ReflectionUpgradeManager.upgrade(ReflectionUpgradeManager.java:122)
at co.uk.rushorm.core.RushCore.upgrade(RushCore.java:358)
at co.uk.rushorm.core.RushCore.access$300(RushCore.java:38)
at co.uk.rushorm.core.RushCore$1.run(RushCore.java:100)
at java.lang.Thread.run(Thread.java:818)

@Stuart-campbell

This comment has been minimized.

Show comment
Hide comment
@Stuart-campbell

Stuart-campbell May 14, 2015

Owner

Does the problem persist with a full uninstall and reinstall? Looks like its related to a change in the relationship between. CaseListResponse and details_user_details field type User.

Thanks

Owner

Stuart-campbell commented May 14, 2015

Does the problem persist with a full uninstall and reinstall? Looks like its related to a change in the relationship between. CaseListResponse and details_user_details field type User.

Thanks

@nagendraksrivastava

This comment has been minimized.

Show comment
Hide comment
@nagendraksrivastava

nagendraksrivastava May 14, 2015

If I have installed the app for the first time this problem is not coming , but if I cleared the app from recent app list and opened the app again then this problem is keep coming. I am completely blocked with this. Can you please help me , I can attached the whole code file if required,

nagendraksrivastava commented May 14, 2015

If I have installed the app for the first time this problem is not coming , but if I cleared the app from recent app list and opened the app again then this problem is keep coming. I am completely blocked with this. Can you please help me , I can attached the whole code file if required,

@Stuart-campbell

This comment has been minimized.

Show comment
Hide comment
@Stuart-campbell

Stuart-campbell May 14, 2015

Owner

Can you share CaseListResponse and User class. Also what metadata tags do you have in your manifest?

Owner

Stuart-campbell commented May 14, 2015

Can you share CaseListResponse and User class. Also what metadata tags do you have in your manifest?

@nagendraksrivastava

This comment has been minimized.

Show comment
Hide comment
@nagendraksrivastava

nagendraksrivastava May 14, 2015

import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;

import java.io.Serializable;

import co.uk.rushorm.core.Rush;
import co.uk.rushorm.core.RushCallback;
import co.uk.rushorm.core.RushCore;

@JsonObject
public class User_details implements Rush, Serializable {

@JsonField(name = "lname")
private String lname = null;

@JsonField(name = "degree")
private String degree = null;

@JsonField(name = "_id")
private String _id;

@JsonField(name = "profile_pic")
private String profile_pic = null;

@JsonField(name = "specialty")
private String specialty = null;

@JsonField(name = "fname")
private String fname = null;

public String getLname() {
    return lname;
}

public void setLname(String lname) {
    this.lname = lname;
}

public String getDegree() {
    return degree;
}

public void setDegree(String degree) {
    this.degree = degree;
}

public String get_id() {
    return _id;
}

public void set_id(String _id) {
    this._id = _id;
}

public String getProfile_pic() {
    return profile_pic;
}

public void setProfile_pic(String profile_pic) {
    this.profile_pic = profile_pic;
}

public String getSpecialty() {
    return specialty;
}

public void setSpecialty(String specialty) {
    this.specialty = specialty;
}

public String getFname() {
    return fname;
}

public void setFname(String fname) {
    this.fname = fname;
}

@Override
public String toString() {
    return "ClassPojo [lname = " + lname + ", degree = " + degree + ", _id = " + _id + ", profile_pic = " + profile_pic + ", specialty = " + specialty + ", fname = " + fname + "]";
}

public User_details() {
}

//Database Calls from Interface
@Override
public void save() {
    RushCore.getInstance().save(this);
}

@Override
public void save(RushCallback callback) {
    RushCore.getInstance().save(this, callback);
}

@Override
public void delete() {
    RushCore.getInstance().delete(this);
}

@Override
public void delete(RushCallback callback) {
    RushCore.getInstance().delete(this, callback);
}

@Override
public String getId() {
    return null;
}

}

nagendraksrivastava commented May 14, 2015

import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;

import java.io.Serializable;

import co.uk.rushorm.core.Rush;
import co.uk.rushorm.core.RushCallback;
import co.uk.rushorm.core.RushCore;

@JsonObject
public class User_details implements Rush, Serializable {

@JsonField(name = "lname")
private String lname = null;

@JsonField(name = "degree")
private String degree = null;

@JsonField(name = "_id")
private String _id;

@JsonField(name = "profile_pic")
private String profile_pic = null;

@JsonField(name = "specialty")
private String specialty = null;

@JsonField(name = "fname")
private String fname = null;

public String getLname() {
    return lname;
}

public void setLname(String lname) {
    this.lname = lname;
}

public String getDegree() {
    return degree;
}

public void setDegree(String degree) {
    this.degree = degree;
}

public String get_id() {
    return _id;
}

public void set_id(String _id) {
    this._id = _id;
}

public String getProfile_pic() {
    return profile_pic;
}

public void setProfile_pic(String profile_pic) {
    this.profile_pic = profile_pic;
}

public String getSpecialty() {
    return specialty;
}

public void setSpecialty(String specialty) {
    this.specialty = specialty;
}

public String getFname() {
    return fname;
}

public void setFname(String fname) {
    this.fname = fname;
}

@Override
public String toString() {
    return "ClassPojo [lname = " + lname + ", degree = " + degree + ", _id = " + _id + ", profile_pic = " + profile_pic + ", specialty = " + specialty + ", fname = " + fname + "]";
}

public User_details() {
}

//Database Calls from Interface
@Override
public void save() {
    RushCore.getInstance().save(this);
}

@Override
public void save(RushCallback callback) {
    RushCore.getInstance().save(this, callback);
}

@Override
public void delete() {
    RushCore.getInstance().delete(this);
}

@Override
public void delete(RushCallback callback) {
    RushCore.getInstance().delete(this, callback);
}

@Override
public String getId() {
    return null;
}

}

@nagendraksrivastava

This comment has been minimized.

Show comment
Hide comment
@nagendraksrivastava

nagendraksrivastava May 14, 2015

import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;

import java.io.Serializable;
import java.util.ArrayList;

import co.uk.rushorm.core.Rush;
import co.uk.rushorm.core.RushCallback;
import co.uk.rushorm.core.RushCore;

@JsonObject
public class CaseListResponse implements Rush, Serializable {

//private String someNewColumn;



private String setSpecialityString;
@JsonField(name = "body")
private String body;
@JsonField(name = "user_details")
private User_details user_details;
@JsonField(name = "is_favourited")
private String is_favourited;
@JsonField(name = "published_on")
private String published_on;
@JsonField(name = "questions")
private ArrayList<Questions> questions;
@JsonField(name = "country")
private String country;
@JsonField(name = "is_solved")
private String is_solved;
@JsonField(name = "title")
private String title;
@JsonField(name = "thumbnail")
private String thumbnail;
@JsonField(name = "_id")
private String _id;
@JsonField(name = "is_thanked")
private String is_thanked;
@JsonField(name = "user_id")
private String user_id;
@JsonField(name = "case_type")
private String case_type;
@JsonField(name = "specialty")
private String[] specialty;


@JsonField(name = "last_updated")
private String lastUpdated;




public CaseListResponse() {
}



public String getLastUpdated() {
    return lastUpdated;
}

public void setLastUpdated(String lastUpdated) {
    this.lastUpdated = lastUpdated;
}


public String getSetSpecialityString() {
    return setSpecialityString;
}

public void setSetSpecialityString(String setSpecialityString) {
    this.setSpecialityString = setSpecialityString;
}


public String getBody() {
    return body;
}

public void setBody(String body) {
    this.body = body;
}

public User_details getUser_details() {
    return user_details;
}

public void setUser_details(User_details user_details) {
    this.user_details = user_details;
}

public String getIs_favourited() {
    return is_favourited;
}

public void setIs_favourited(String is_favourited) {
    this.is_favourited = is_favourited;
}

public String getPublished_on() {
    return published_on;
}

public void setPublished_on(String published_on) {
    this.published_on = published_on;
}

public ArrayList<Questions> getQuestions() {
    return questions;
}

public void setQuestions(ArrayList<Questions> questions) {
    this.questions = questions;
}

public String getCountry() {
    return country;
}

public void setCountry(String country) {
    this.country = country;
}

public String getIs_solved() {
    return is_solved;
}

public void setIs_solved(String is_solved) {
    this.is_solved = is_solved;
}

public String getTitle() {
    return title;
}

public void setTitle(String title) {
    this.title = title;
}

public String getThumbnail() {
    return thumbnail;
}

public void setThumbnail(String thumbnail) {
    this.thumbnail = thumbnail;
}

public String get_id() {
    return _id;
}

public void set_id(String _id) {
    this._id = _id;
}

public String getIs_thanked() {
    return is_thanked;
}

public void setIs_thanked(String is_thanked) {
    this.is_thanked = is_thanked;
}

public String getUser_id() {
    return user_id;
}

public void setUser_id(String user_id) {
    this.user_id = user_id;
}

public String getCase_type() {
    return case_type;
}

public void setCase_type(String case_type) {
    this.case_type = case_type;
}

public String[] getSpecialty() {
    return specialty;
}

public void setSpecialty(String[] specialty) {
    this.specialty = specialty;
}

@Override
public String toString() {
    return "ClassPojo [body = " + body + ", user_details = " + user_details + ", is_favourited = " + is_favourited + ", published_on = " + published_on + ", questions = " + questions + ", country = " + country + ", is_solved = " + is_solved + ", title = " + title + ", thumbnail = " + thumbnail + ", _id = " + _id + ", is_thanked = " + is_thanked + ", user_id = " + user_id + ", case_type = " + case_type + ", specialty = " + specialty + "]";
}

// public String getSomeNewColumn() {
// return someNewColumn;
//}

//public void setSomeNewColumn(String someNewColumn) {
  //  this.someNewColumn = someNewColumn;
//}

//Database Calls from Interface
@Override
public void save() {
    RushCore.getInstance().save(this);
}

@Override
public void save(RushCallback callback) {
    RushCore.getInstance().save(this, callback);
}

@Override
public void delete() {
    RushCore.getInstance().delete(this);
}

@Override
public void delete(RushCallback callback) {
    RushCore.getInstance().delete(this, callback);
}

@Override
public String getId() {
    return RushCore.getInstance().getId(this);
}

}

nagendraksrivastava commented May 14, 2015

import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject;

import java.io.Serializable;
import java.util.ArrayList;

import co.uk.rushorm.core.Rush;
import co.uk.rushorm.core.RushCallback;
import co.uk.rushorm.core.RushCore;

@JsonObject
public class CaseListResponse implements Rush, Serializable {

//private String someNewColumn;



private String setSpecialityString;
@JsonField(name = "body")
private String body;
@JsonField(name = "user_details")
private User_details user_details;
@JsonField(name = "is_favourited")
private String is_favourited;
@JsonField(name = "published_on")
private String published_on;
@JsonField(name = "questions")
private ArrayList<Questions> questions;
@JsonField(name = "country")
private String country;
@JsonField(name = "is_solved")
private String is_solved;
@JsonField(name = "title")
private String title;
@JsonField(name = "thumbnail")
private String thumbnail;
@JsonField(name = "_id")
private String _id;
@JsonField(name = "is_thanked")
private String is_thanked;
@JsonField(name = "user_id")
private String user_id;
@JsonField(name = "case_type")
private String case_type;
@JsonField(name = "specialty")
private String[] specialty;


@JsonField(name = "last_updated")
private String lastUpdated;




public CaseListResponse() {
}



public String getLastUpdated() {
    return lastUpdated;
}

public void setLastUpdated(String lastUpdated) {
    this.lastUpdated = lastUpdated;
}


public String getSetSpecialityString() {
    return setSpecialityString;
}

public void setSetSpecialityString(String setSpecialityString) {
    this.setSpecialityString = setSpecialityString;
}


public String getBody() {
    return body;
}

public void setBody(String body) {
    this.body = body;
}

public User_details getUser_details() {
    return user_details;
}

public void setUser_details(User_details user_details) {
    this.user_details = user_details;
}

public String getIs_favourited() {
    return is_favourited;
}

public void setIs_favourited(String is_favourited) {
    this.is_favourited = is_favourited;
}

public String getPublished_on() {
    return published_on;
}

public void setPublished_on(String published_on) {
    this.published_on = published_on;
}

public ArrayList<Questions> getQuestions() {
    return questions;
}

public void setQuestions(ArrayList<Questions> questions) {
    this.questions = questions;
}

public String getCountry() {
    return country;
}

public void setCountry(String country) {
    this.country = country;
}

public String getIs_solved() {
    return is_solved;
}

public void setIs_solved(String is_solved) {
    this.is_solved = is_solved;
}

public String getTitle() {
    return title;
}

public void setTitle(String title) {
    this.title = title;
}

public String getThumbnail() {
    return thumbnail;
}

public void setThumbnail(String thumbnail) {
    this.thumbnail = thumbnail;
}

public String get_id() {
    return _id;
}

public void set_id(String _id) {
    this._id = _id;
}

public String getIs_thanked() {
    return is_thanked;
}

public void setIs_thanked(String is_thanked) {
    this.is_thanked = is_thanked;
}

public String getUser_id() {
    return user_id;
}

public void setUser_id(String user_id) {
    this.user_id = user_id;
}

public String getCase_type() {
    return case_type;
}

public void setCase_type(String case_type) {
    this.case_type = case_type;
}

public String[] getSpecialty() {
    return specialty;
}

public void setSpecialty(String[] specialty) {
    this.specialty = specialty;
}

@Override
public String toString() {
    return "ClassPojo [body = " + body + ", user_details = " + user_details + ", is_favourited = " + is_favourited + ", published_on = " + published_on + ", questions = " + questions + ", country = " + country + ", is_solved = " + is_solved + ", title = " + title + ", thumbnail = " + thumbnail + ", _id = " + _id + ", is_thanked = " + is_thanked + ", user_id = " + user_id + ", case_type = " + case_type + ", specialty = " + specialty + "]";
}

// public String getSomeNewColumn() {
// return someNewColumn;
//}

//public void setSomeNewColumn(String someNewColumn) {
  //  this.someNewColumn = someNewColumn;
//}

//Database Calls from Interface
@Override
public void save() {
    RushCore.getInstance().save(this);
}

@Override
public void save(RushCallback callback) {
    RushCore.getInstance().save(this, callback);
}

@Override
public void delete() {
    RushCore.getInstance().delete(this);
}

@Override
public void delete(RushCallback callback) {
    RushCore.getInstance().delete(this, callback);
}

@Override
public String getId() {
    return RushCore.getInstance().getId(this);
}

}

@Stuart-campbell

This comment has been minimized.

Show comment
Hide comment
@Stuart-campbell

Stuart-campbell May 14, 2015

Owner

Pretty sure its because User_details getId returns null. It needs to return

RushCore.getInstance().getId(this);

Update that and see if there is still a problem.

Owner

Stuart-campbell commented May 14, 2015

Pretty sure its because User_details getId returns null. It needs to return

RushCore.getInstance().getId(this);

Update that and see if there is still a problem.

@nagendraksrivastava

This comment has been minimized.

Show comment
Hide comment
@nagendraksrivastava

nagendraksrivastava May 14, 2015

No Sorry that I have changed just to check if I am returning null then also problem persists or not.

I was returning same RushCore.getInstance().getId(this); and the same error was coming

nagendraksrivastava commented May 14, 2015

No Sorry that I have changed just to check if I am returning null then also problem persists or not.

I was returning same RushCore.getInstance().getId(this); and the same error was coming

@Stuart-campbell

This comment has been minimized.

Show comment
Hide comment
@Stuart-campbell

Stuart-campbell May 14, 2015

Owner

I'm wondering if having a field called _id is a problem. As this would normally be the primary key. Can you try renaming this?

Owner

Stuart-campbell commented May 14, 2015

I'm wondering if having a field called _id is a problem. As this would normally be the primary key. Can you try renaming this?

@nagendraksrivastava

This comment has been minimized.

Show comment
Hide comment
@nagendraksrivastava

nagendraksrivastava May 14, 2015

Okay Let me try , will update you with in 5 min, for information I am getting data from rest api, then clearing previous table using

CaseListResponse caseList = new CaseListResponse();
caseList.delete();
and then saving it to database again.

I hope it is not creating any problem

Thanks

nagendraksrivastava commented May 14, 2015

Okay Let me try , will update you with in 5 min, for information I am getting data from rest api, then clearing previous table using

CaseListResponse caseList = new CaseListResponse();
caseList.delete();
and then saving it to database again.

I hope it is not creating any problem

Thanks

@Stuart-campbell

This comment has been minimized.

Show comment
Hide comment
@Stuart-campbell

Stuart-campbell May 14, 2015

Owner

As a side not this feature may be useful

http://www.rushorm.com/advanced.html#import

You can pass in the name of you id field as well so would need your own.
Eg..

List<Rush> objects = RushCore.getInstance().deserialize(jsonString, "_id");

Then you could bulk save which is quicker. This would add any new objects or updated any with the same _id. Wouldn't delete any not in the download which might be the only problem.

RushCore.getInstance.save(objects);

Is dependent on the root element being the root class name. Might not be any help but thought i'd point it out.

Owner

Stuart-campbell commented May 14, 2015

As a side not this feature may be useful

http://www.rushorm.com/advanced.html#import

You can pass in the name of you id field as well so would need your own.
Eg..

List<Rush> objects = RushCore.getInstance().deserialize(jsonString, "_id");

Then you could bulk save which is quicker. This would add any new objects or updated any with the same _id. Wouldn't delete any not in the download which might be the only problem.

RushCore.getInstance.save(objects);

Is dependent on the root element being the root class name. Might not be any help but thought i'd point it out.

@nagendraksrivastava

This comment has been minimized.

Show comment
Hide comment
@nagendraksrivastava

nagendraksrivastava May 14, 2015

Let me try it out , will update you , I tried changing _id to other variable but no luck

nagendraksrivastava commented May 14, 2015

Let me try it out , will update you , I tried changing _id to other variable but no luck

@nagendraksrivastava

This comment has been minimized.

Show comment
Hide comment
@nagendraksrivastava

nagendraksrivastava May 14, 2015

List objects = RushCore.getInstance().deserialize(jsonString, "_id"); In this case also User_detail class and CaseListResponse class should implement Rush ?

Can you just give me a more example by using CaseListResponse and User_detail

nagendraksrivastava commented May 14, 2015

List objects = RushCore.getInstance().deserialize(jsonString, "_id"); In this case also User_detail class and CaseListResponse class should implement Rush ?

Can you just give me a more example by using CaseListResponse and User_detail

@Stuart-campbell

This comment has been minimized.

Show comment
Hide comment
@Stuart-campbell

Stuart-campbell May 14, 2015

Owner

May require a little json restructure. But with json that looks like this. (Written without checking)

{
    "com_cc_dailyrounds_response_CaseListResponse": [
    {
            "_id": "35c4b394-49db-45e1-bb0f-9de7ac788e07",
            user_details: {"_id", "myidstring" ..other properties },
            ... other properties
     }]
}

List<CaseListResponse> objects = RushCore.getInstance().deserialize(jsonString, "_id", CaseListResponse.class);
CaseListResponse object =  objects.get(0);      
object.save();

Thats the basic idea. Also you would want to remove the _id field completely and access it via getId()

Owner

Stuart-campbell commented May 14, 2015

May require a little json restructure. But with json that looks like this. (Written without checking)

{
    "com_cc_dailyrounds_response_CaseListResponse": [
    {
            "_id": "35c4b394-49db-45e1-bb0f-9de7ac788e07",
            user_details: {"_id", "myidstring" ..other properties },
            ... other properties
     }]
}

List<CaseListResponse> objects = RushCore.getInstance().deserialize(jsonString, "_id", CaseListResponse.class);
CaseListResponse object =  objects.get(0);      
object.save();

Thats the basic idea. Also you would want to remove the _id field completely and access it via getId()

@nagendraksrivastava

This comment has been minimized.

Show comment
Hide comment
@nagendraksrivastava

nagendraksrivastava May 14, 2015

Okay great , One last question which is understood but just asking to make it sure that CaseLisrResponse class must implement rush right ? then only
List objects = RushCore.getInstance().deserialize(jsonString, "_id", CaseListResponse.class); will work ?

nagendraksrivastava commented May 14, 2015

Okay great , One last question which is understood but just asking to make it sure that CaseLisrResponse class must implement rush right ? then only
List objects = RushCore.getInstance().deserialize(jsonString, "_id", CaseListResponse.class); will work ?

@Stuart-campbell

This comment has been minimized.

Show comment
Hide comment
@Stuart-campbell

Stuart-campbell May 14, 2015

Owner

Correct. And the same with any child objects.

Owner

Stuart-campbell commented May 14, 2015

Correct. And the same with any child objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment