使用ORMLite配置文件:java.sql.SQLException:可序列化字段必须指定dataType = DataType.SERIALIZABLE

时间:2013-08-15 17:56:23

标签: android ormlite sqlexception

我正在尝试通过ORMLite在我的Android应用程序中使用生成的类(使用Google App Engine生成)。我创建了一个配置文件,如下所示:

# --table-start--
dataClass=com.name.app.entities.customerendpoint.model.Customer
tableName=customer
# --table-fields-start--
# --field-start--
fieldName=key
generatedId=false
# --field-end--
# --field-start--
fieldName=firstName
#columnName=lastClickDate
# --field-end--
# --field-start--
fieldName=lastName
#indexName=clickcount_name_idx
# --field-end--
# --field-start--
fieldName=email
# --field-end--
# --field-start--
fieldName=postcode
# --field-end--
# --field-start--
fieldName=birthDate
dataType=DataType.SERIALIZABLE
#foreign=true
# --field-end--
# --field-start--
fieldName=gender
# --field-end--
# --field-start--
fieldName=facebookId
# --field-end--
# --field-start--
fieldName=googleId
# --field-end--
# --field-start--
fieldName=pictureUrl
# --field-end--
# --field-start--
fieldName=verificationCode
# --field-end--
# --table-fields-end--
# --table-end--
#################################

在我的DBHelper的构造函数中,我指的是这个文件:
super(context, "APP", null, 1, R.raw.ormlite_config);

不幸的是,当我创建表时,会引发SQLException:

java.sql.SQLException: ORMLite can't store unknown class class com.google.api.client.util.DateTime for field 'birthDate'. Serializable fields must specify dataType=DataType.SERIALIZABLE

奇怪的是我确实将birthDate字段指定为Serializable:

fieldName=birthDate
dataType=DataType.SERIALIZABLE

有没有人知道我做错了什么,或者它是ORMLite中的错误?

1 个答案:

答案 0 :(得分:1)

您需要在dataPersister=SERIALIZABLE中保留数据类型,而不是{/ 1}}在配置文件中。