I am deploying a simple Java application for the Google App Engine.
I have a simple JPA object containing the key as my generated identifier.
import javax.persistence.*; @Entity public class MyEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private com.google.appengine.api.datastore.Key key; ...
As soon as I saved this object. I can view the key id, for example ...
long id = entity.getKey().getId();
Do you know how I can use the same identifier to return my entity? Something like that...
Query query = em.createQuery("SELECT e FROM MyEntity e WHERE e.key.id = :myId"); query.setParameter("myId", id);
The above does not work. I know that I can return it by passing the key as a parameter, but I would like to know if I can use a long identifier.
source share