[英]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.我正在使用 android studio 并从事一个 android 项目。 I tried to create a database with around 57 table.
我试图创建一个包含大约 57 个表的数据库。 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
无法创建数据库 java.sql.SQLException: 无法为类 com.icecube.iceman.model.dto.AddressEntity 找到名称为“warehouseOverstore”的声明字段
In addressEntity hasn't got any field called warehouseOverstore.
在addressEntity 中没有任何名为warehouseOverstore 的字段。 Never was declared too.
从来没有被宣布过。 In ormlite_config doesn't containing any references to warehouseOverstore.
在 ormlite_config 中不包含对仓库Overstore 的任何引用。
If i leave out that createTable instruction, the app run without any error.如果我省略了 createTable 指令,应用程序就会运行而不会出现任何错误。 What's the problem?
有什么问题?
ormlite_config extract: ormlite_config提取:
# --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.谢谢你的帮助。
Are you creating this project from scratch or you are trying to modify existing project? 您是从头开始创建此项目还是要修改现有项目? If it's a new project why you are using OrmLite?
如果是新项目,为什么要使用OrmLite? Google created Room recently and I really recommend you to use it ;).
Google最近创建了Room,我真的建议您使用它;)。 I used OrmLite too, but it generates long cold start, so I decided to leave it.
我也使用了OrmLite,但是它会产生很长的冷启动时间,所以我决定离开它。
If you really need an OrmLite, do you have variable called warehouseOverstore
anywhere in your project? 如果你真的需要一个OrmLite,你有变量,名为
warehouseOverstore
项目中的任何地方?
DaoManager.clearCache(); DaoManager.clearCache(); command solved it.
命令解决了它。 Placed it in that class constructor, which extends OrmLiteSqliteOpenHelper
将其放在该类构造函数中,该类构造函数扩展了OrmLiteSqliteOpenHelper
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.