首页 文章

java-cassnadra object冻结地址映射的注释<text,frozen <list <frozen <address >>>>,

提问于
浏览
3

我正在尝试将数据插入到Cassandra中(2.1.9)我的Java对象有一个UDT列表的映射 . 在运行代码时,我收到有关@Frozen注释的错误 . 我正在使用DataStax(2.1.9)库 . http://docs.datastax.com/en/drivers/java/2.1/index.html?com/datastax/driver/mapping/annotations/FrozenValue.html

create table user{
        name text,
        addresses map<text, frozen<list<frozen<address>>>>,
}

我的Java类

public class User{
    private String name;
    @FrozenValue
    private Map<String, List<AddressUDT>> addresses;
}

但我得到了以下错误

java.lang.IllegalArgumentException: Error while checking frozen types on field addresses of entity com.dante.data.model.User: expected AddressUDT to be frozen but was not frozen
    at com.datastax.driver.mapping.AnnotationChecks.validateAnnotations(AnnotationChecks.java:73) ~[cassandra-driver-mapping-2.1.7.jar:na]
    at com.datastax.driver.mapping.AnnotationParser.parseEntity(AnnotationParser.java:81) ~[cassandra-driver-mapping-2.1.7.jar:na]
    at com.datastax.driver.mapping.MappingManager.getMapper(MappingManager.java:148) ~[cassandra-driver-mapping-2.1.7.jar:na]
    at com.datastax.driver.mapping.MappingManager.mapper(MappingManager.java:105) ~[cassandra-driver-mapping-2.1.7.jar:na]
    at com.dante.data.migration.dao.UserMigrationDao.insertUsersToCassandra(UserMigrationDao.java:389) ~[UserMigrationDao.class:na]
    at com.dante.data.migration.service.impl.UserMigration.insertUsersToCassandra(UserMigration.java:32) ~[UserMigration.class:na]
    at com.dante.data.migration.controller.DataMigrationController.migrateUserDetails(DataMigrationController.java:93) ~[DataMigrationController.class:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) ~[spring-web-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776) ~[spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705) ~[spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) [servlet-api.jar:na]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) [spring-webmvc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723) [servlet-api.jar:na]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) [catalina.jar:6.0.44]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:6.0.44]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) [catalina.jar:6.0.44]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [catalina.jar:6.0.44]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [catalina.jar:6.0.44]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) [catalina.jar:6.0.44]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [catalina.jar:6.0.44]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) [catalina.jar:6.0.44]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) [tomcat-coyote.jar:6.0.44]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620) [tomcat-coyote.jar:6.0.44]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) [tomcat-coyote.jar:6.0.44]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]

请提出解决方案

2 回答

  • 4
    @Frozen("map<text, frozen<list<frozen<AddressUDT>>>>")
    private Map<String, List<AddressUDT>> addresses;
    
  • 3

    我没试过这个,但是文档声明@FrozenValue在你的情况下是:

    @Frozen("map<text, frozen<list<address>>>")

    因此,从create table语句中定义为冻结的地址不匹配 . 尝试删除冻结的地址或使用上面的注释,包括附加的冻结地址 .

相关问题