Room Persistence库-具有List< Video>的嵌套对象@Embedded不起作用. [英] Room Persistence library - Nested Object with List<Video>, @Embedded doesn't work.

查看:47
本文介绍了Room Persistence库-具有List< Video>的嵌套对象@Embedded不起作用.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VideoList对象,我想使用房间库保存它,但是当我尝试在公共列表list = null时使用@Embedded时;它给我下面的错误:错误:(23,24)错误:无法弄清楚如何将该字段保存到数据库中.您可以考虑为其添加类型转换器.

I have a VideoList object which I want to save using room library but when i try to use @Embedded with public List list = null; it is giving me below error: Error:(23, 24) error: Cannot figure out how to save this field into database. You can consider adding a type converter for it.

VideoList类如下.

VideoList Class is as below.

@Entity
public class VideoList {


@PrimaryKey
public String id;

public String title;
public String viewType;
public Integer sortingOrder = null;
public String componentSlug;
public String endPoint = null;

@Embedded
public List<Video> list = null;
public boolean hidden = false; }




Any suggestions? 

推荐答案

在大多数情况下,由于它们是复杂的对象,因此您无法使用转换器生成String!

Most of the times you can't use the converter to produce a String since they are complex objects!

为了不重复答案,在另一个相同的问题中,您可以阅读我的答案.

To not repeat the answer, in the other same question you can read my answer.

这篇关于Room Persistence库-具有List&lt; Video&gt;的嵌套对象@Embedded不起作用.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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