Skip to content Skip to sidebar Skip to footer

Android + ORMLite + Java.sql.Timestamp

I have an Android project which uses ORMLite. All works fine, but for some fields in database it uses java.sql.Timestamp as field type. It worked fine on ORMLite 4.10, which I used

Solution 1:

Sorry about this @st1ing. This certainly can be a bug in ORMLite but I suspect rather that it may be an incompatibility. In version 4.14, we had to make a change how Serializable fields are handled. Upgrade notes are online. To quote:

In addition, serialized types must also now specify their dataType value. You should use DataType.SERIALIZABLE to continue to store serialized objects in the database. This will allow us to add direct support for other serialized types in the future without breaking backwards compatibility.

If you already have Serializable data (byte[] or other objects) stored in a database then you will need to add something like the following to your fields:

@DatabaseField(dataType = DataType.SERIALIZABLE)
Serializable field;

Actually, the exception is trying to give you a hint as to how to fix you problem:

Serializable fields must specify dataType=DataType.SERIALIZABLE

So try adding that to your Timestamp field. Let me know if it works.


Post a Comment for "Android + ORMLite + Java.sql.Timestamp"