简体   繁体   English

无法创建数据库 java.sql.SQLException: 找不到名称为 ... 的声明字段用于类

[英]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

You need to regenerate ormlite_config file by running OrmLiteConfigUtil.java您需要通过运行OrmLiteConfigUtil.java重新生成ormlite_config文件

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.sql.SQLException:找不到数据库ID X名称“数据库”。 - java.sql.SQLException: Could not find database ID X name 'database'. java.sql.SQLException:找不到存储过程 - java.sql.SQLException: Could not find stored procedure java.sql.SQLException 无效的对象名称 - java.sql.SQLException Invalid object name java.sql.SQLException:无效的列名 - java.sql.SQLException: Invalid column name 未报告的异常java.sql.SQLException;必须被抓或宣布被扔? - Unreported exception java.sql.SQLException; must be caught or declared to be thrown? 如何避免java.sql.SQLException:[Microsoft] [ODBC Microsoft Access Driver]找不到文件“(未知)” - how to avoid java.sql.SQLException:[Microsoft][ODBC Microsoft Access Driver] could not find file '(unkown)' java.sql.SQLException:用户'root'@'localhost'的访问被拒绝。 无法建立与数据库服务器的连接 - java.sql.SQLException: Access denied for user 'root'@'localhost'. Could not create connection to database server java.sql.SQLException:无法加载类:com.mysql.jdbc.Driver - java.sql.SQLException: Unable to load class: com.mysql.jdbc.Driver Tomcat:java.sql.SQLException:无法从 ClassLoader 加载类:com.mysql.jdbc.Driver - Tomcat: java.sql.SQLException: Unable to load class: com.mysql.jdbc.Driver from ClassLoader java.sql.SQLException:网络适配器无法建立连接 - java.sql.SQLException: The Network Adapter could not establish the connection
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM