spring-data-couchbase バージョン 1.0.0.RELEASE でオブジェクトを永続化しようとしています。
package com.spring.data.couchbase.user;
import javax.persistence.Entity;
import org.springframework.data.annotation.Id;
import org.springframework.data.couchbase.core.mapping.Field;
@Entity
public class User {
@Id
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Field("lastName")
private String lastName;
public String getLastName() {
return lastName;
}
public void setLastname(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@Field("firstName")
private String firstName;
}
オブジェクトをcouchbaseデータベースに保存しようとすると、MappingExceptionが発生します。以下の完全なスタック。AFAIK全体は問題ないようです。spring-data-couchbase によって期待される追加機能はありますか?
Exception in thread "main" org.springframework.data.mapping.model.MappingException: An ID property is needed, but not found on this entity.
at org.springframework.data.couchbase.core.convert.MappingCouchbaseConverter.write(MappingCouchbaseConverter.java:316)
at org.springframework.data.couchbase.core.convert.MappingCouchbaseConverter.write(MappingCouchbaseConverter.java:50)
at org.springframework.data.couchbase.core.CouchbaseTemplate.save(CouchbaseTemplate.java:298)
at org.springframework.data.couchbase.core.CouchbaseTemplate.save(CouchbaseTemplate.java:149)
at org.springframework.data.couchbase.repository.support.SimpleCouchbaseRepository.save(SimpleCouchbaseRepository.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:358)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:343)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.data.couchbase.repository.support.ViewPostProcessor$ViewInterceptor.invoke(ViewPostProcessor.java:80)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy18.save(Unknown Source)
at com.spring.data.couchbase.user.MyService.doWork(MyService.java:27)
at com.spring.data.couchbase.user.Main.main(Main.java:17)