0

我正在尝试通过 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 字段为可序列化的:

fieldName=birthDate
dataType=DataType.SERIALIZABLE

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

4

1 回答 1

1

您需要通过dataPersister=SERIALIZABLE,而不是dataType=DataType.SERIALIZABLE在您的配置文件中保存数据类型。

于 2014-10-14T11:49:06.923 回答