Ok ... a little more trial and error. See if these changes fix your
issue using the reverse save method I proposed above. They fixed mine.

Change Employee

 @Extension(vendorName="datanucleus", key="gae.encoded-pk",
value="true")
        private String id;
  @Persistent
    @Extension(vendorName="datanucleus", key="gae.pk-id",
value="true")
    private Long keyId;

Change Evaluation

        @Extension(vendorName="datanucleus", key="gae.encoded-pk",
value="true")
        private String id;
  @Persistent
    @Extension(vendorName="datanucleus", key="gae.pk-id",
value="true")
    private Long keyId;

On Aug 24, 10:37 pm, Simon Blackwell <[email protected]> wrote:
> 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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to