Hi,
when object is saved using the pm.makePersistent() method, the new
related child object is saved automatically. Since both objects are
new, App Engine creates two new entities in the same entity group.

[]'s
Diego

On 25 ago, 20:01, Rodrigo Sol <rodrigo...@gmail.com> wrote:
> Hi,
>
> Probably this is a newbie question, but I spent a whole day searching
> for a solution without success.
>
> I want to create an one-to-one relationships between two entities
> (City and Costumer). I have a form where I create new costumers. When
> I save this new costumer into the datastore a new "register" for city
> is created causing one unnecessary duplication.
>
> I am using unowned relationship and my model is above:
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> Class City{
>
>     @PrimaryKey
>     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>     @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
>     private String key;
>
>     @Persistent
>     private String nome;
>     ...
>
> }
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> Class Costumer{
>
>     @PrimaryKey
>     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>     @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
>     private String key;
>
>     @Persistent
>     private String cityKey;
>     ...
>
> }
>
> And I am saving the Costumer class in this function:
>
>     public void create(Costumer costumer) {
>         PersistenceManager pm = Conn.get();
>         try {
>                 pm.makePersistent(costumer);
>         } finally {
>             pm.close();
>         }
>         return errors;
>
>     }
>
> So, what I am doing wrong? It seems that in owned relationships this
> behavior (duplicate child object) is expected, but I can not
> understand why it is happening here.
>
> I would be grateful if anyone could help?
>
> Thanks in advance.
>
> Rodrigo Sol

-- 
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-j...@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