Keine Konverter gefunden, die in der Lage Konvertierung vom Typ org.bson.Typen.ObjectId Typ int

Bin ich mit Spring data und mongodb, um alle Products mit dieser Funktion:

@Repository
public class ProductDao  {

    @Autowired
    private MongoOperations mongoOperations;
    public List<Product> getAll() {
            return mongoOperations.findAll(Product.class);
        }
}

Mein Produkt-Klasse:

@Document(collection = Product.COLLECTION_NAME)
public class Product implements Serializable {

    public Product() {
    }

    public static final String COLLECTION_NAME = "product";

    @Id
    private String _id;
    private String name;
    private DateTime date_time;
    private int fk_properties;
    private List<Integer> fk_parts;
}

Fehler:

    org.springframework.core.convert.ConverterNotFoundException: 
No converter found capable of converting from type org.bson.types.ObjectId to type int

Wie es zu lösen ist?

UPDATE:

Ich habe spring-core-4.1.0.RELEASE.jar im lib-Ordner, die wohl gehören erforderlichen Konverter.

UPDATE 2:
Dokument

{ 
    "_id" : ObjectId("5449567cdf97f277c50d1ce2"), 
    "name" : "2014 ISF", 
    "auction_start" : ISODate("2014-12-08T12:00:00.000+0200"), 
    "auction_end" : ISODate("2014-12-08T14:00:00.000+0200"), 
    "listed" : "F", 
    "fk_product_property" : ObjectId("5229567cdf97f277c50d1ce2"), 
    "fk_parts" : [
        ObjectId("5339567cdf97f277c50d1ce2"), 
        ObjectId("5349567cdf97f277c50d1ce2")
    ]
}
  • Sie haben Dokumente in der Produkt-Auflistung, deren id-Typ ist integer? db.product.find({"_id" : {$type : 16}})
  • Es gibt nichts, während die Ausführung db.product.find({"_id" : {$type : 16}}) in Befehlszeile...
  • Können Sie Ihre Beispiel-Dokument, wird es uns helfen, festzustellen, datatype mismatch-Probleme.
InformationsquelleAutor J.Olufsen | 2014-09-17
Schreibe einen Kommentar