Thursday, 9 June 2011

Spring Data Mongo Repositories

Understandably, spring data is very new so the documentation isn't 100% accurate. There are several mistakes in the documentation at the moment, but there was one that got me stuck for ages. I was getting this exception in setting up the PersonRepository:


Unsupported id class! Only class java.lang.String,class org.bson.types.ObjectId,class java.math.BigInteger are supported!

The problem was the had this interface definition:

public interface PersonRepository extends PagingAndSortingRepository<person,long>{

where as instead I should have had:

public interface PersonRepository extends PagingAndSortingRepository PagingAndSortingRepository<person,String> {

No comments:

Post a Comment