问题描述
我有这样一列:
@DatabaseField(dataType = DataType.TIME_STAMP)
Timestamp time;
当我创建DAO我得到这个异常:
When I create the DAO I get this exception:
java.lang.IllegalArgumentException: Field class class java.sql.Timestamp for
field FieldType:name=time,class=Vote is not valid for data persister
com.j256.ormlite.field.types.TimeStampType@334ecfe8
它已经有一天,我正在尝试不同的方法,没有工作。请注意,我有我的ormlite罐子更新到4.41。
It's been one day that I'm trying different methods and none is working. Note that I have updated my ormlite jar to 4.41.
推荐答案
哎哟。为的java.sql.Timestamp
和 java.sql.Date
字段支持的版本4.41,它看起来像他们都有一个相关的错误。这些被固定在4.42版本。
Ouch. Support for java.sql.Timestamp
and java.sql.Date
fields was added in ORMLite version 4.41 and it looks like they both have an associated bug. These were fixed in version 4.42.
在此期间,我想你也许可以通过删除的dataType
说明来修复它。我认为,它应该能够自动检测的类型。问题是,当你指定了数据类型。
In the meantime, I think you might be able to fix it by removing the dataType
specifier. I think that it should be able to auto-detect the type. The problem is when you are specifying the data-type.
// no dataType specified
@DatabaseField
Timestamp time;
这篇关于创建具有ormlite时间戳列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!