{"action":"created","issue":{"url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/135","repository_url":"https://api.github.com/repos/derjust/spring-data-dynamodb","labels_url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/135/labels{/name}","comments_url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/135/comments","events_url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/135/events","html_url":"https://github.com/derjust/spring-data-dynamodb/issues/135","id":294236837,"number":135,"title":"[Spring Boot] Repository.save() exception","user":{"login":"Tutankhamon","id":4370021,"avatar_url":"https://avatars0.githubusercontent.com/u/4370021?v=4","gravatar_id":"","url":"https://api.github.com/users/Tutankhamon","html_url":"https://github.com/Tutankhamon","followers_url":"https://api.github.com/users/Tutankhamon/followers","following_url":"https://api.github.com/users/Tutankhamon/following{/other_user}","gists_url":"https://api.github.com/users/Tutankhamon/gists{/gist_id}","starred_url":"https://api.github.com/users/Tutankhamon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tutankhamon/subscriptions","organizations_url":"https://api.github.com/users/Tutankhamon/orgs","repos_url":"https://api.github.com/users/Tutankhamon/repos","events_url":"https://api.github.com/users/Tutankhamon/events{/privacy}","received_events_url":"https://api.github.com/users/Tutankhamon/received_events","type":"User","site_admin":false},"labels":[{"id":196423234,"url":"https://api.github.com/repos/derjust/spring-data-dynamodb/labels/question","name":"question","color":"321389","default":true},{"id":407256771,"url":"https://api.github.com/repos/derjust/spring-data-dynamodb/labels/update%20documentation","name":"update documentation","color":"c91a9d","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-02-04T22:22:50Z","updated_at":"2018-02-06T17:33:26Z","closed_at":"2018-02-06T17:33:26Z","author_association":"NONE","body":"Hello Again. After some time passed to get MySQL and DynamoDB coexisting in the same Spring Boot app, I thought that everything had to work. But it is not so... Now I'm trying to **SAVE** the same business object I successful read, **with no success**.\r\n\r\nHere some code of mine:\r\n\r\nBusinessObject\r\n```java\r\npackage com.somotic.scm.model;\r\n\r\nimport com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;\r\nimport com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;\r\nimport com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey;\r\nimport com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;\r\nimport org.springframework.data.annotation.Id;\r\n\r\nimport java.io.Serializable;\r\nimport java.util.Date;\r\n\r\n@DynamoDBTable(tableName = \"DeviceValue\")\r\npublic class DeviceValue implements Serializable {\r\n    @Id\r\n    private DeviceValueKey key;\r\n\r\n    @DynamoDBAttribute(attributeName = \"Value\")\r\n    private int value;\r\n\r\n    @DynamoDBAttribute(attributeName = \"LastChange\")\r\n    private Date lastChange;\r\n\r\n    public DeviceValue(DeviceValueKey key, int value, Date lastChange) {\r\n        this.key = key;\r\n        this.value = value;\r\n        this.lastChange = lastChange;\r\n    }\r\n\r\n    public DeviceValue(Long contextID, String tag, int value, Date lastChange) {\r\n        this(new DeviceValueKey(contextID, tag), value, lastChange);\r\n    }\r\n\r\n    public DeviceValue() {}\r\n\r\n    @DynamoDBHashKey(attributeName = \"ContextID\")\r\n    public Long getContextID() {\r\n        return (key != null) ? key.getContextID() : null;\r\n    }\r\n\r\n    public void setContextID(Long contextID) {\r\n        if (key == null) {\r\n            key = new DeviceValueKey();\r\n        }\r\n        key.setContextID(contextID);\r\n    }\r\n\r\n    @DynamoDBRangeKey(attributeName = \"TAG\")\r\n    public String getTag() {\r\n        return (key != null) ? key.getTag() : null;\r\n    }\r\n\r\n    public void setTag(String tag) {\r\n        if (key == null) {\r\n            key = new DeviceValueKey();\r\n        }\r\n        key.setTag(tag);\r\n    }\r\n\r\n    public DeviceValueKey getKey() {\r\n        return key;\r\n    }\r\n\r\n    public void setKey(DeviceValueKey key) {\r\n        this.key = key;\r\n    }\r\n\r\n    public int getValue() {\r\n        return value;\r\n    }\r\n\r\n    public void setValue(int value) {\r\n        this.value = value;\r\n    }\r\n\r\n    public Date getLastChange() {\r\n        return lastChange;\r\n    }\r\n\r\n    public void setLastChange(Date lastChange) {\r\n        this.lastChange = lastChange;\r\n    }\r\n}\r\n```\r\nThe composite key of the business object above:\r\n```java\r\npackage com.somotic.scm.model;\r\n\r\nimport com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;\r\nimport com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey;\r\n\r\nimport java.io.Serializable;\r\n\r\npublic class DeviceValueKey implements Serializable {\r\n    private Long contextID;\r\n    private String tag;\r\n\r\n    DeviceValueKey() {}\r\n\r\n    public DeviceValueKey(Long contextID, String tag) {\r\n        this.contextID = contextID;\r\n        this.tag =  tag;\r\n    }\r\n\r\n    @DynamoDBHashKey\r\n    public Long getContextID() {\r\n        return contextID;\r\n    }\r\n\r\n    public void setContextID(Long contextID) {\r\n        this.contextID = contextID;\r\n    }\r\n\r\n    @DynamoDBRangeKey\r\n    public String getTag() {\r\n        return tag;\r\n    }\r\n\r\n    public void setTag(String tag) {\r\n        this.tag = tag;\r\n    }\r\n}\r\n```\r\nThe repository:\r\n```java\r\npackage com.somotic.scm.repo.nosql;\r\n\r\nimport com.somotic.scm.model.DeviceValue;\r\nimport com.somotic.scm.model.DeviceValueKey;\r\nimport org.springframework.data.repository.CrudRepository;\r\n\r\npublic interface DeviceValueRepository extends CrudRepository<DeviceValue, DeviceValueKey> {\r\n\r\n}\r\n```\r\nThe calling code:\r\n```java\r\npublic void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {\r\n            String message = new String(body, \"UTF-8\");\r\n            // State message management \"<TAG>:<VALUE>\"\r\n            String[] splitted = message.split(\":\");\r\n            String tag = splitted[0];\r\n            int value = Integer.parseInt(splitted[1]);\r\n            \r\n            // NoSQL Update\r\n            Optional<DeviceValue> deviceValueOptional = deviceValueRepository.findById(new DeviceValueKey(contextId, tag));\r\n            DeviceValue deviceValue = null;\r\n            if (deviceValueOptional.isPresent()) {\r\n                deviceValue = deviceValueOptional.get();\r\n                deviceValue.setValue(value);\r\n                deviceValue.setLastChange(new Date());\r\n            } else {\r\n                deviceValue = new DeviceValue(new DeviceValueKey(contextId, tag), value, new Date());\r\n            }\r\n            deviceValueRepository.save(deviceValue);\r\n\r\n            // Notify listeners\r\n        }\r\n```\r\nAnd last but not least, The Exception:\r\n```\r\ncom.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: not supported; requires @DynamoDBTyped or @DynamoDBTypeConverted\r\n\tat com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$Rules$NotSupported.set(StandardModelFactories.java:664) ~[aws-java-sdk-dynamodb-1.11.232.jar:na]\r\n\tat com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$Rules$NotSupported.set(StandardModelFactories.java:650) ~[aws-java-sdk-dynamodb-1.11.232.jar:na]\r\n\tat com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$AbstractRule.convert(StandardModelFactories.java:709) ~[aws-java-sdk-dynamodb-1.11.232.jar:na]\r\n\tat com.amazonaws.services.dynamodbv2.datamodeling.StandardModelFactories$AbstractRule.convert(StandardModelFactories.java:691) ~[aws-java-sdk-dynamodb-1.11.232.jar:na]\r\n\tat com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperFieldModel.convert(DynamoDBMapperFieldModel.java:138) ~[aws-java-sdk-dynamodb-1.11.232.jar:na]\r\n\tat com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper$SaveObjectHandler.execute(DynamoDBMapper.java:721) ~[aws-java-sdk-dynamodb-1.11.232.jar:na]\r\n\tat com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.save(DynamoDBMapper.java:623) ~[aws-java-sdk-dynamodb-1.11.232.jar:na]\r\n\tat com.amazonaws.services.dynamodbv2.datamodeling.AbstractDynamoDBMapper.save(AbstractDynamoDBMapper.java:123) ~[aws-java-sdk-dynamodb-1.11.232.jar:na]\r\n\tat org.socialsignin.spring.data.dynamodb.core.DynamoDBTemplate.save(DynamoDBTemplate.java:141) ~[spring-data-dynamodb-5.0.1.jar:na]\r\n\tat org.socialsignin.spring.data.dynamodb.repository.support.SimpleDynamoDBCrudRepository.save(SimpleDynamoDBCrudRepository.java:121) ~[spring-data-dynamodb-5.0.1.jar:na]\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161]\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]\r\n\tat java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]\r\n\tat org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:377) ~[spring-data-commons-2.0.3.RELEASE.jar:2.0.3.RELEASE]\r\n\tat org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) ~[spring-data-commons-2.0.3.RELEASE.jar:2.0.3.RELEASE]\r\n\tat org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:629) ~[spring-data-commons-2.0.3.RELEASE.jar:2.0.3.RELEASE]\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.3.RELEASE.jar:5.0.3.RELEASE]\r\n\tat org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:593) ~[spring-data-commons-2.0.3.RELEASE.jar:2.0.3.RELEASE]\r\n\tat org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:578) ~[spring-data-commons-2.0.3.RELEASE.jar:2.0.3.RELEASE]\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.3.RELEASE.jar:5.0.3.RELEASE]\r\n\tat org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) ~[spring-data-commons-2.0.3.RELEASE.jar:2.0.3.RELEASE]\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.3.RELEASE.jar:5.0.3.RELEASE]\r\n\tat org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-5.0.3.RELEASE.jar:5.0.3.RELEASE]\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.3.RELEASE.jar:5.0.3.RELEASE]\r\n\tat org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) ~[spring-data-commons-2.0.3.RELEASE.jar:2.0.3.RELEASE]\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.3.RELEASE.jar:5.0.3.RELEASE]\r\n\tat org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.0.3.RELEASE.jar:5.0.3.RELEASE]\r\n\tat com.sun.proxy.$Proxy115.save(Unknown Source) ~[na:na]\r\n\tat com.somotic.scm.mq.MQContext$MQListener.handleDelivery(MQContext.java:87) ~[classes/:na]\r\n\tat com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:149) ~[amqp-client-5.1.2.jar:5.1.2]\r\n\tat com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:100) [amqp-client-5.1.2.jar:5.1.2]\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_161]\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_161]\r\n\tat java.lang.Thread.run(Thread.java:748) [na:1.8.0_161]\r\n```\r\nI repeat: **I have absolutely no problem when READING from DynamoDB (*repository.findById()*)**. This problem is raised only when I try to save something. Could it be the composite key? Initially, I thought it was a problem related to the \"java.util.Date lastChange\" field, but the same exception is raised when I add *DynamoDBIgnore Annotation* to that field. Any clue? thanks in advance."},"comment":{"url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/comments/363501361","html_url":"https://github.com/derjust/spring-data-dynamodb/issues/135#issuecomment-363501361","issue_url":"https://api.github.com/repos/derjust/spring-data-dynamodb/issues/135","id":363501361,"user":{"login":"derjust","id":2053353,"avatar_url":"https://avatars0.githubusercontent.com/u/2053353?v=4","gravatar_id":"","url":"https://api.github.com/users/derjust","html_url":"https://github.com/derjust","followers_url":"https://api.github.com/users/derjust/followers","following_url":"https://api.github.com/users/derjust/following{/other_user}","gists_url":"https://api.github.com/users/derjust/gists{/gist_id}","starred_url":"https://api.github.com/users/derjust/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derjust/subscriptions","organizations_url":"https://api.github.com/users/derjust/orgs","repos_url":"https://api.github.com/users/derjust/repos","events_url":"https://api.github.com/users/derjust/events{/privacy}","received_events_url":"https://api.github.com/users/derjust/received_events","type":"User","site_admin":false},"created_at":"2018-02-06T17:33:26Z","updated_at":"2018-02-06T17:33:26Z","author_association":"OWNER","body":"Updated [wiki](https://github.com/derjust/spring-data-dynamodb/wiki/Use-Hash-Range-keys)."}}
{"actor":{"display_login":"derjust"}}