1
@Entity
public class AgendaEntity {
    @Id public long id;

    private Map unitMap;


    public Map getUnitMap() {
        return unitMap;
    }

    public void setUnitMap(Map unitMap) {
        this.unitMap = unitMap;
    }
}

导致以下错误:-

error: [ObjectBox] Field type "java.util.Map" is not supported. Consider making the target an @Entity, or using @Convert or @Transient on the field (see docs).
4

1 回答 1

2

如果您无法避免使用地图(例如,您有固定数量的条目吗?),请为您的地图编写转换器,有关详细信息,请参阅自定义类型文档

例子:

@Convert(converter = MyUnitConverter.class, dbType = String.class)
private Map unitMap;

MyUnitConverter 必须由您实现。

于 2018-02-21T10:51:36.437 回答