Creating Timestamp column with ormlite

孤者浪人 提交于 2019-12-10 21:08:24

问题


I have a column like this:

@DatabaseField(dataType = DataType.TIME_STAMP)
Timestamp time;

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

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.


回答1:


Support for java.sql.Timestamp and java.sql.Date fields was added in ORMLite version 4.41 but they had an associated bug. These were fixed in version 4.42.

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;


来源:https://stackoverflow.com/questions/10957983/creating-timestamp-column-with-ormlite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!