Exception when createOrUpdate with ormlite with an field is unique

74 Views Asked by At

I have a table:

@DatabaseTable
public class Author {
    @DatabaseField(columnName = "id", generatedId = true)
    public Long id;
    @DatabaseField
    public String name;
    @DatabaseField(unique = true)
    public String href;

    public Author() {
    }
    public void add(){
        try {
            DbHelper.getHelper().getAuthorDao().createOrUpdate(this);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

How ever when i add an element it have exception:

Unable to run insert stmt on object Author@86abe70: INSERT INTO `author` (`name` ,`href` ) VALUES (?,?)

I need get status of update command but because there Exception, i can't What is best to practice ?

0

There are 0 best solutions below