Search code examples
javaandroidormlite

Unable to create databases java.sql.SQLException: Could not find declared field with name ... for class


Hy!

I'm using android studio and working on an android project. I tried to create a database with around 57 table. I have the following error message:

Unable to create datbases java.sql.SQLException: Could not find declared field with name 'warehouseOverstore' for class com.icecube.iceman.model.dto.AddressEntity

In addressEntity hasn't got any field called warehouseOverstore. Never was declared too. In ormlite_config doesn't containing any references to warehouseOverstore.

If i leave out that createTable instruction, the app run without any error. What's the problem?

ormlite_config extract:

# --table-start--
dataClass=com.icecube.iceman.model.dto.AddressEntity
tableName=address
# --table-fields-start--
fieldName=id
columnName=_id
generatedId=true
fieldName=name
columnName=name
fieldName=zip
columnName=zip
fieldName=country
columnName=country
fieldName=city
columnName=city
fieldName=district
columnName=district
fieldName=street
columnName=street
fieldName=streetnumber
columnName=streetNumber
fieldName=block
columnName=block
fieldName=building
columnName=building
fieldName=type
columnName=type
# --table-fields-end--
# --table-end--

AddressEntity:

@DatabaseTable(tableName="address" )
public class AddressEntity implements Serializable {

private static final long serialVersionUID = 1L;

//----------------------------------------------------------------------
// ENTITY PRIMARY KEY ( BASED ON A SINGLE FIELD )
//----------------------------------------------------------------------
@DatabaseField(generatedId = true, columnName = "_id")
private Integer    id           ;


//----------------------------------------------------------------------
// ENTITY DATA FIELDS 
//----------------------------------------------------------------------
@DatabaseField(columnName="name")
private String     name         ;

@DatabaseField(columnName="zip", canBeNull=false)
private String     zip          ;

@DatabaseField(columnName="country", canBeNull=false)
private String     country      ;

@DatabaseField(columnName="city", canBeNull=false)
private String     city         ;

@DatabaseField(columnName="district")
private String     district     ;

@DatabaseField(columnName="street")
private String     street       ;

@DatabaseField(columnName="streetNumber")
private String     streetnumber ;

@DatabaseField(columnName="block")
private String     block        ;

@DatabaseField(columnName="building")
private String     building     ;

@DatabaseField(columnName="type", canBeNull=false)
private String     type         ;

// After that just constructor and getter/setters. No reference on warehauseOverstore

Thank You for your helps.


Solution

  • DaoManager.clearCache(); command solved it. Placed it in that class constructor, which extends OrmLiteSqliteOpenHelper