使用 ORMLite 配置文件:java.sql.SQLException:Serializable 字段必须指定 dataType=DataType.SERIALIZABLE [英] Using ORMLite config file: java.sql.SQLException: Serializable fields must specify dataType=DataType.SERIALIZABLE

查看:53
本文介绍了使用 ORMLite 配置文件:java.sql.SQLException:Serializable 字段必须指定 dataType=DataType.SERIALIZABLE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to use a generated class (generated using the Google App Engine) in my Android application through ORMLite. I've created a config file as follows:

# --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);

In the constructor of my DBHelper I'm referring to this file:
super(context, "APP", null, 1, R.raw.ormlite_config);

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

Unfortenately, when I'm creating the table an SQLException is raised:

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 字段指定为可序列化:

The weird thing is I definitely specified the birthDate field to be Serializable:

fieldName=birthDate
dataType=DataType.SERIALIZABLE

有人知道我做错了什么还是 ORMLite 中的错误?

Does anyone have a clue what I'm doing wrong or is it a bug in ORMLite?

推荐答案

你需要在你的配置中通过 dataPersister=SERIALIZABLE 来持久化数据类型,而不是 dataType=DataType.SERIALIZABLE文件.

You need to persist datatype by dataPersister=SERIALIZABLE, instead dataType=DataType.SERIALIZABLE in your config file.

这篇关于使用 ORMLite 配置文件:java.sql.SQLException:Serializable 字段必须指定 dataType=DataType.SERIALIZABLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆