Frank
Frank

Reputation: 740

No entity was found matching the key with GAE Java

I'm trying to get an Entity directly from the DatastoreService using the id. So this is my code:

Key repairKey=KeyFactory.createKey("Repair",Integer.parseInt(request.getParameter("ID")));

Entity repair=        datastore.get(repairKey);

The result is this message:

com.google.appengine.api.datastore.EntityNotFoundException: No entity was found matching the key: Repair(336)

But it is impossible because this entity with this ID exists in the DB.

How can i fix it?

Upvotes: 0

Views: 767

Answers (1)

Frank
Frank

Reputation: 740

The Entity repair have a parent entity, so i correct with this code:

Key keycar= KeyFactory.stringToKey(request.getParameter("keycar"));
    Key repairKey= KeyFactory.createKey(keycar,"Repair", Integer.parseInt(request.getParameter("ID")));

Upvotes: 1

Related Questions