发送多值customdata

时间:2015-10-22 02:38:06

标签: amazon-dynamodb dynamo-local

发送自定义对象集时,我遇到以下错误。 2015年10月21日下午7:28:38 com.amazonaws.services.dynamodbv2.datamodeling.marshallers.ObjectSetToStringSetMarshaller marshall 警告:将一组非String对象封送到DynamoDB StringSet。除非你真的知道你在做什么,否则你将无法从DynamoDB中读取这些对象:这可能是一个错误。如果您确实知道自己在做什么,请忽略此警告,但请考虑使用自定义封送程序。 com.amazonaws.AmazonServiceException:一个或多个参数值无效:字符串集可能不为空(Service:AmazonDynamoDBv2; Status Code:400; Error Code:ValidationException; Request ID:S61P89234SI8PE61M8I9QTG8RNVV4KQNSO5AEMVJF66Q9ASUAAJG)     在com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1181)     在com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:766)     在com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:485)     在com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:306) 在com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.invoke(AmazonDynamoDBClient.java:1799)     在com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient.updateItem(AmazonDynamoDBClient.java:1614)     在com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper $ SaveObjectHandler.doUpdateItem(DynamoDBMapper.java:1241)     在com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper $ 2.executeLowLevelRequest(DynamoDBMapper.java:937)     在com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper $ SaveObjectHandler.execute(DynamoDBMapper.java:1120)     在com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.java:966)     在com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.java:758)     at .dao.impl.DeviceDaoImpl.addDevice(DeviceDaoImpl.java:57)     at .admin.device.service.impl.DeviceServiceImpl.addDevice(DeviceServiceImpl.java:38)

这是发生这种情况的代码段

    @DynamoDBTable(tableName="Device")
public class Device extends BaseEntity implements Serializable{
private Set<AsscoiatedReviewer> asscoiatedReviewers ;
// getters setter

    public Device addDevice(Device device) {
        device.setDeviceId(generateId());
        device.setCreatedTime(getCurrentTime());
        if (!StringUtils.isNullOrEmpty(device.getPincode())) {
            // get lat and long - do this for review team as well
            //TODO : move it to common place that can be accessed for review team too
            setLatLong(device);
            // calculate the distances between this organization and reviewers
            calculateAsscoiatedReviewersDistances(device);
        }
        mapper.save(device);
        Device device1 = mapper.load(Device.class, device.getDeviceId());


        return device1;
    }

    private void calculateAsscoiatedReviewersDistances(Device device)  {
        if(StringUtils.isNullOrEmpty(device.getPincode())) return;
        try {
            List<ReviewTeam> ReviewTeam = reviewTeamDao.getAllReviewTeams();
            Set<AsscoiatedReviewer> asscoiatedReviewers = new HashSet<AsscoiatedReviewer>();
            /*for (ReviewTeam reviewTeam2 : ReviewTeam) {
                if(StringUtils.isNullOrEmpty(reviewTeam2.getPincode())) continue;
                AsscoiatedReviewer asscoiatedReviewer = new AsscoiatedReviewer();
                asscoiatedReviewer.setReviewTeamId(reviewTeam2.getReviewTeamId());
                double distance = distance(new Double(device.getLat()), new Double(device.getLongt()),
                        new Double(reviewTeam2.getLat()), new Double(reviewTeam2.getLongt()));
                asscoiatedReviewer.setDistance(new Double(distance).toString());
                asscoiatedReviewers.add(asscoiatedReviewer);
            }*/
            device.setAsscoiatedReviewers(asscoiatedReviewers);

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
    public class AsscoiatedReviewer implements Serializable,Comparable {

    /**
     *
     */
    private static final long serialVersionUID = -1906388056843006046L;

    private String distance;
    private String reviewTeamId;
// getters setters 
}

似乎错误发生在以下行 device.setAsscoiatedReviewers(asscoiatedReviewers);

这应该被编组/解组并发送给亚马逊吗?任何帮助将不胜感激。

更新: 我在asscoiatedReviewers中填充数据时收到以下异常警告:将一组非String对象封送到DynamoDB StringSet。除非你真的知道你在做什么,否则你将无法从DynamoDB中读取这些对象:这可能是一个错误。如果您确实知道自己在做什么,请忽略此警告,但请考虑使用自定义封送程序。 com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException:无法在没有自定义封送程序或@DynamoDBDocument批注的情况下解组输入in.forus.foruscare.entity.AsscoiatedReviewer类。     在com.amazonaws.services.dynamodbv2.datamodeling.ConversionSchemas $ StandardItemConverter.getObjectUnmarshaller(ConversionSchemas.java:590)     在com.amazonaws.services.dynamodbv2.datamodeling.ConversionSchemas $ StandardItemConverter.augment(ConversionSchemas.java:497)     在com.amazonaws.services.dynamodbv2.datamodeling.ConversionSchemas $ StandardItemConverter.getMemberUnmarshaller(ConversionSchemas.java:466)     在com.amazonaws.services.dynamodbv2.datamodeling.ConversionSchemas $ StandardItemConverter.getObjectSetUnmarshaller(ConversionSchemas.java:520)这意味着我需要编写自定义编组器或使用DynamoDBDocument注释进行annoate。如果是,这是一组自定义对象,你可以发送指向marshaller的简单示例的指针。我偶然看到其他的marshllers,他们似乎没有解释我需要什么

0 个答案:

没有答案