I have a problem, that Appengine generates duplicate keys and thus my
objects get overwritten. I have following classes:

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ProfileEntity  {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    @Persistent
    private ImageDescriptionEntity mainImage;
    ...
}

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ImageDescriptionEntity implements Serializable {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    @Persistent(dependent="true")
    private ImageDataEntity thumbnail;

    @Persistent(dependent="true")
    private ImageDataEntity fullsize;
    ...
}

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ImageDataEntity implements Serializable {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    @Persistent
    private Blob data;
    ...
}

Here's the code I'm using to store the images:

ProfileEntity profile = (ProfileEntity) pm.getObjectById
(ProfileEntity.class, key);
ImageDescriptionEntity imageDescription = new ImageDescriptionEntity
();
ImageDataEntity fullsize = new ImageDataEntity();
imageDescription.setFullsize(fullsize);
ImageDataEntity thumbnail = new ImageDataEntity();
imageDescription.setThumbnail(thumbnail);
profile.setMainImage(imageDescription);
pm.makePersistent(profile);
//the problem: fullsize.getKey().equals(thumbnail.getKey())

What happens, is that thumbnail and fullsize get assigned the same key
from appengine and thus fullsize gets overwritten by the tumbnail.

I'm not sure what I'm doing wrong.
-- 
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