Same issue here. The trouble seems to be in DatastoreFieldManager

private Key getKeyForObject(Object pc) {
    ApiAdapter adapter = getStoreManager().getOMFContext
().getApiAdapter();
    Object internalPk = adapter.getTargetKeyForSingleFieldIdentity
(adapter.getIdForObject(pc));
    ObjectManager om = getObjectManager();
    AbstractClassMetaData acmd =
        om.getMetaDataManager().getMetaDataForClass(pc.getClass(),
getClassLoaderResolver());
    return EntityUtils.getPkAsKey(internalPk, acmd, om);
  }

internalPk is null because adapter.getIdForObject(pc) is null

public Object getIdForObject(Object obj)
    {
        if (!isPersistable(obj))
        {
            return null;
        }
        return ((PersistenceCapable)obj).jdoGetObjectId(); <--- this
returns null
    }

The error only seems to occur when saving child objects. In the case
from the original poster, that means if the Employee were saved after
adding the Evaluation in a transient state or if the Evaluation were
added to an Employee that pointed to a persistent object, the code
would work. Of course, this means that the entire state of the
Employee would be re-saved.

Try replacing "em.persist(evaluationBean);" with

EmployeeBean e = evaluationBean.getEmployee();
em.persist(e);

However, this may result in an error "Attempt was made to manually set
the id component of a Key primary key" ... even if you have no code
that sets a primary key! If you trace into the AppEngine code you will
find this comment:

 if (key.getName() == null) {
        // This means an id was provided to an incomplete Key,
        // and that means the user is trying to set the id manually,
which
        // we don't support.

I'm suspicious that if you use real Keys instead of encoded strings,
stuff may work. Unfortunately, this means that the same class files
can't be used on the client and sever because GWT does not support
client side Key references.

On Aug 12, 1:03 am, kfc <oni...@gmail.com> wrote:
> I have the same problem
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to