Problem with UpdateBuilder

202 views
Skip to first unread message

Javier Hinmel

unread,
Dec 7, 2011, 11:13:10 PM12/7/11
to ormlite...@googlegroups.com
Hi, I'm using ORMLite 4.30 in Android app. I have an exception when trying to execute my UpdateBuilder.

StackTrace:
java.lang.IllegalArgumentException: Column name cannot be set twice from lastDownloadFailure to lastDownload
    at com.j256.ormlite.stmt.BaseSelectArg.setMetaInfo(BaseSelectArg.java:53)
    at com.j256.ormlite.stmt.BaseSelectArg.setMetaInfo(BaseSelectArg.java:72)
    at com.j256.ormlite.stmt.query.BaseComparison.appendArgOrValue(BaseComparison.java:64)
    at com.j256.ormlite.stmt.query.BaseComparison.appendValue(BaseComparison.java:50)
    at com.j256.ormlite.stmt.query.SetValue.appendValue(SetValue.java:19)
    at com.j256.ormlite.stmt.query.BaseComparison.appendSql(BaseComparison.java:41)
    at com.j256.ormlite.stmt.query.SetValue.appendSql(SetValue.java:19)
    at com.j256.ormlite.stmt.UpdateBuilder.appendStatementStart(UpdateBuilder.java:127)
    at com.j256.ormlite.stmt.StatementBuilder.appendStatementString(StatementBuilder.java:117)
    at com.j256.ormlite.stmt.StatementBuilder.buildStatementString(StatementBuilder.java:101)
    at com.j256.ormlite.stmt.StatementBuilder.prepareStatement(StatementBuilder.java:76)
    at com.j256.ormlite.stmt.UpdateBuilder.prepare(UpdateBuilder.java:38)
...

Here my code:

Entity
@DatabaseTable(tableName = "SyncPDVs")
public class SyncPDVs  {
   
    public static final String IDPDV = "idPDV";   
    @DatabaseField(id = true, canBeNull= false, columnName = IDPDV)
    private int idPDV;
    public int getIdpdv(){ return idPDV; }

    public static final String RECORDTYPE = "recordType";
    @DatabaseField(canBeNull = false, columnName = RECORDTYPE)
    private String recordType;
    public String getRecordtype(){ return recordType; }

    public static final String LASTDOWNLOAD = "lastDownload";
    @DatabaseField(columnName = LASTDOWNLOAD)
    private Date lastDownload;
    public Date getLastdownload(){ return lastDownload; }

    public static final String LASTDOWNLOADFAILURE = "lastDownloadFailure";
    @DatabaseField(columnName = LASTDOWNLOADFAILURE)
    private Date lastDownloadFailure;
    public Date getLastdownloadfailure(){ return lastDownloadFailure; }

    public SyncPDVs() {}
    .........
   ...
}

My method:

private void updateDates(SyncPDVs item) throws SQLException {
        Dao<SyncPDVs, Integer> dao = getDao(SyncPDVs.class);
        UpdateBuilder<SyncPDVs, Integer> builder = dao.updateBuilder();
       
        builder = dao.updateBuilder();
        builder.updateColumnValue(SyncPDVs.LASTDOWNLOAD, item.getLastdownload());   
        builder.updateColumnValue(SyncPDVs.LASTDOWNLOADFAILURE, item.getLastdownloadfailure());
       
        builder.where()
            .eq(SyncPDVs.RECORDTYPE, item.getRecordtype())
            .and()
            .eq(SyncPDVs.IDPDV, item.getIdpdv());
           
        dao.update(builder.prepare());   
    }

Thanks for your help!
Javier
Reply all
Reply to author
Forward
0 new messages