ORMLite的dataType = DataType.SERIALIZABLE不起作用 [英] ORMLite dataType=DataType.SERIALIZABLE doesn't work

查看:541
本文介绍了ORMLite的dataType = DataType.SERIALIZABLE不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我宣布我喜欢的类型为 SERIALIZABLE 由ORMLite文件规定,但我仍然可以:


  

ORMLite不能存储现场task_titles未知类接口java.io.Serializable接口。序列化字段必须指定的dataType = DataType.SERIALIZABLE


我的code是这样的:

  @DatabaseField(dataType的= DataType.SERIALIZABLE)
私人序列化task_titles;公共用户(){
    task_titles =新的ArrayList<串GT;();
}

我用,因为ArrayList是序列化的,但没有运气也试过。

 私人的ArrayList<串GT; task_titles;

有关其他原因(在我的控制之外的应用限制),它是不是在这种情况下,一个很好的选择,以创建一个包含任务标题另一个表。下面是完整的异常:

  02-13 21:07:12.593:E / AndroidRuntime(15500):了java.lang.RuntimeException:无法启动活动ComponentInfo {lemonhat.snote / lemonhat.snote.MainActivity} :了java.lang.RuntimeException:无法对类级lemonhat.snote.db.User创建RuntimeExcepitionDao
02-13 21:07:12.593:E / AndroidRuntime(15500):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
...
02-13 21:07:12.593:E / AndroidRuntime(15500):了java.lang.RuntimeException:由所造成类类lemonhat.snote.db.User无法创建RuntimeExcepitionDao
02-13 21:07:12.593:E / AndroidRuntime(15500):在com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.getRuntimeExceptionDao(OrmLiteSqliteOpenHelper.java:260)
02-13 21:07:12.593:E / AndroidRuntime(15500):在lemonhat.snote.db.DatabaseHelper.getUserDataDao(DatabaseHelper.java:109)
02-13 21:07:12.593:E / AndroidRuntime(15500):在lemonhat.snote.MainActivity.onCreate(MainActivity.java:80)
...
02-13 21:07:12.593:E / AndroidRuntime(15500):值java.sql.SQLException:致ORMLite不能储存未知的类接口java.io.Serializable接口现场sort_order_of_lists。序列化字段必须指定的dataType = DataType.SERIALIZABLE
。02-13 21:07:12.593:E / AndroidRuntime(15500):在com.j256.ormlite.field.FieldType<&初始化GT;(FieldType.java:183)
02-13 21:07:12.593:E / AndroidRuntime(15500):在com.j256.ormlite.table.DatabaseTableConfig.convertFieldConfigs(DatabaseTableConfig.java:236)
02-13 21:07:12.593:E / AndroidRuntime(15500):在com.j256.ormlite.table.DatabaseTableConfig.extractFieldTypes(DatabaseTableConfig.java:101)
02-13 21:07:12.593:E / AndroidRuntime(15500):在com.j256.ormlite.dao.BaseDaoImp​​l.initialize(BaseDaoImp​​l.java:151)
...


解决方案

  

ORMLite不能存储现场sort_order_of_lists未知类接口java.io.Serializable接口。序列化字段必须指定的dataType = DataType.SERIALIZABLE


我缺少的东西吗?这个错误是在谈论领域 sort_order_of_lists ,但你是显示另一个字段:

  @DatabaseField(dataType的= DataType.SERIALIZABLE)
私人序列化task_titles;

我怀疑 sort_order_of_lists 缺少的dataType = DataType.SERIALIZABLE 注释字段。是那场在基类?

如果不是那么问题我怀疑你使用的是Android专用的表配置功能,你需要,因为它是与你的对象同步来重新生成表的配置。看到此功能的链接了解详情:


  

http://ormlite.com/docs/table-config


I have declared my type to be SERIALIZABLE as specified by ORMLite documentation, but I still get:

ORMLite can't store unknown class interface java.io.Serializable for field 'task_titles'. Serializable fields must specify dataType=DataType.SERIALIZABLE

My code looks like this:

@DatabaseField(dataType=DataType.SERIALIZABLE) 
private Serializable task_titles;

public User() {
    task_titles = new ArrayList<String>();
}

I also tried using since ArrayList is serializable but without luck.

private ArrayList<String> task_titles; 

For other reasons (limitations in applications outside my control), it is not a good option in this case to create another table containing the task titles. Here's the full exception:

02-13 21:07:12.593: E/AndroidRuntime(15500): java.lang.RuntimeException: Unable to start activity ComponentInfo{lemonhat.snote/lemonhat.snote.MainActivity}: java.lang.RuntimeException: Could not create RuntimeExcepitionDao for class class lemonhat.snote.db.User
02-13 21:07:12.593: E/AndroidRuntime(15500):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
...
02-13 21:07:12.593: E/AndroidRuntime(15500): Caused by: java.lang.RuntimeException: Could not create RuntimeExcepitionDao for class class lemonhat.snote.db.User
02-13 21:07:12.593: E/AndroidRuntime(15500):    at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.getRuntimeExceptionDao(OrmLiteSqliteOpenHelper.java:260)
02-13 21:07:12.593: E/AndroidRuntime(15500):    at lemonhat.snote.db.DatabaseHelper.getUserDataDao(DatabaseHelper.java:109)
02-13 21:07:12.593: E/AndroidRuntime(15500):    at lemonhat.snote.MainActivity.onCreate(MainActivity.java:80)
...
02-13 21:07:12.593: E/AndroidRuntime(15500): Caused by: java.sql.SQLException: ORMLite can't store unknown class interface java.io.Serializable for field 'sort_order_of_lists'. Serializable fields must specify dataType=DataType.SERIALIZABLE
02-13 21:07:12.593: E/AndroidRuntime(15500):    at com.j256.ormlite.field.FieldType.<init>(FieldType.java:183)
02-13 21:07:12.593: E/AndroidRuntime(15500):    at com.j256.ormlite.table.DatabaseTableConfig.convertFieldConfigs(DatabaseTableConfig.java:236)
02-13 21:07:12.593: E/AndroidRuntime(15500):    at com.j256.ormlite.table.DatabaseTableConfig.extractFieldTypes(DatabaseTableConfig.java:101)
02-13 21:07:12.593: E/AndroidRuntime(15500):    at com.j256.ormlite.dao.BaseDaoImpl.initialize(BaseDaoImpl.java:151)
...

解决方案

ORMLite can't store unknown class interface java.io.Serializable for field 'sort_order_of_lists'. Serializable fields must specify dataType=DataType.SERIALIZABLE

Am I missing something? This error is talking about the field sort_order_of_lists but you are showing another field:

@DatabaseField(dataType=DataType.SERIALIZABLE) 
private Serializable task_titles;

I suspect that the sort_order_of_lists is missing the dataType=DataType.SERIALIZABLE annotation field. Is that field in a base class?

If that is not the problem then I suspect you are using the table-config feature for Android and you need to re-generate the table-config because it is out of sync with your objects. See the link for more details on this feature:

http://ormlite.com/docs/table-config

这篇关于ORMLite的dataType = DataType.SERIALIZABLE不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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