Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Couchbase 映射数据类型的映射异常_Couchbase_Spring Data Couchbase - Fatal编程技术网

Couchbase 映射数据类型的映射异常

Couchbase 映射数据类型的映射异常,couchbase,spring-data-couchbase,Couchbase,Spring Data Couchbase,在couchBase中保存地图类型数据时,我遇到了一个异常 原因:org.springframework.data.mapping.MappingException:找不到java.lang.Object类型的PersistentEntity 我在数据模型中做了一张地图 @Data public class test { private Map<String,Object> testMap; } 但是失败了 { "dummyMap":{ "key1

在couchBase中保存地图类型数据时,我遇到了一个异常

原因:org.springframework.data.mapping.MappingException:找不到java.lang.Object类型的PersistentEntity

我在数据模型中做了一张地图

@Data
public class test { 
  private Map<String,Object> testMap;
 }
但是失败了

{  
   "dummyMap":{  
      "key1":"val1",
      "key2":"val2",
      "objects":[  
         {  
            "key1":"val1",
            "key2":"val2"
         }
      ]
   }
}
例外

原因:java.lang.IllegalArgumentException:基本类型不能为null

我想这是因为阵列。请让我知道我做错了什么


我使用的是spring data couchbase 2.0.4版。发行版。

请使用下面的代码,因为它的类型为null,couchbase映射转换器无法读取文档 这一定是工作

@Override
    @SuppressWarnings("unchecked")
    protected <R> R read(final TypeInformation<R> type, final CouchbaseDocument source, final Object parent) {
        if (type == null)
            return (R) source.export();
        if (Object.class == typeMapper.readType(source, type).getType()) {
            return (R) source.export();
        } else {
            return super.read(type, source, parent);
        }
    }
    
@覆盖
@抑制警告(“未选中”)
受保护的R读取(最终类型信息类型、最终CouchbaseDocument源、最终对象父对象){
if(type==null)
返回(R)source.export();
if(Object.class==typeMapper.readType(source,type).getType()){
返回(R)source.export();
}否则{
返回super.read(类型、源、父级);
}
}

这是因为阵列。面对同样的问题。
{  
   "dummyMap":{  
      "key1":"val1",
      "key2":"val2",
      "objects":[  
         {  
            "key1":"val1",
            "key2":"val2"
         }
      ]
   }
}
@Override
    @SuppressWarnings("unchecked")
    protected <R> R read(final TypeInformation<R> type, final CouchbaseDocument source, final Object parent) {
        if (type == null)
            return (R) source.export();
        if (Object.class == typeMapper.readType(source, type).getType()) {
            return (R) source.export();
        } else {
            return super.read(type, source, parent);
        }
    }