HY!
我正在使用android studio并在Android项目上工作。我试图用大约57个表创建一个数据库。我有以下错误消息:
无法创建数据库java.sql.SQLException:找不到 已声明的字段名称' warehouseOverstore'上课 com.icecube.iceman.model.dto.AddressEntity
在addressEntity中没有任何名为warehouseOverstore的字段。决不 也宣布了。在ormlite_config中不包含任何引用 仓库超市。
如果我省略了createTable指令,应用程序运行时没有任何错误。问题是什么?
ormlite_config 提取:
@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
AddressEntity:
LOCK TABLES aggregated_table WRITE;
INSERT INTO aggregation_table
SELECT CAST(EXTRACT('epoch' FROM timestamp)/60 AS BIGINT)*60 AS ts, COUNT(aggregated_value)
FROM aggregated_table
WHERE aggregated_flag = 0
GROUP BY ts;
UPDATE aggregated_table SET aggregated_flag = 1 WHERE aggregated_flag = 0;
UNLOCK TABLES
感谢您的帮助。
答案 0 :(得分:0)
您是从头开始创建此项目还是尝试修改现有项目? 如果这是一个新项目,为什么你使用OrmLite? Google最近创建了Room,我真的建议你使用它;)。我也使用了OrmLite,但它会产生很长的冷启动,所以我决定离开它。
如果您确实需要OrmLite,您的项目中是否有名为warehouseOverstore
的变量?
答案 1 :(得分:0)
DaoManager.clearCache();命令解决了它。将它放在该类构造函数中,该构造函数扩展了OrmLiteSqliteOpenHelper