Hello,
I'm using JPA with SDK 1.2.5 and I'm having a problem with multiple
owned One To One relationships where the relationships are to the same
type. The code is as below and Contributor class has three owned One
to One relationships to ContentValue.
What I'm finding is that when I set one of the One to One properties
in one transaction (e.g. picutre) in one request and then later on in
a different request and transaction I retrieve another of the One to
One properties (e.g. tagData), I get back the ContentValue I set for
the first property (picture).
I'm doing the following to set the property:
Contributor contributor = <load contributor here>;
ContentValue picture = contributor.getPicture();
if ( picture == null ) {
picture = new ContentValue();
contributor.setPicture( picture );
pictureContent.setContentValueType( ContentValueType.PICTURE );
}
...
If anyone knows why I'm having this problem, please let me know.
Regards,
Len
Contributor.java
----------------
package abc;
//import com.google.appengine.api.datastore.Key;
//import com.google.appengine.api.datastore.KeyFactory;
import org.datanucleus.jpa.annotations.Extension;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Embedded;
import javax.persistence.FetchType;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Date;
@Entity
public class Contributor {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk",
value="true")
private String id;
@Enumerated
private String firstName;
@Enumerated
private String lastName;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY )
private ContentValue picture;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY )
private ContentValue thumbnailPicture;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY )
private ContentValue tagData;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getFirstName() {
return firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getLastName() {
return lastName;
}
public void setPicture(ContentValue picture) {
this.picture = picture;
}
public ContentValue getPicture() {
return picture;
}
public void setThumbnailPicture(ContentValue thumbnailPicture) {
this.thumbnailPicture = thumbnailPicture;
}
public ContentValue getThumbnailPicture() {
return thumbnailPicture;
}
public void setTagData(ContentValue tagData) {
this.tagData = tagData;
}
public ContentValue getTagData() {
return tagData;
}
}
ContentValue.java
-----------------
package abc;
import org.datanucleus.jpa.annotations.Extension;
import com.google.appengine.api.datastore.Blob;
import javax.persistence.AttributeOverrides;
import javax.persistence.Entity;
import javax.persistence.CascadeType;
import javax.persistence.Enumerated;
import javax.persistence.Embedded;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
@Entity
public class ContentValue {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk",
value="true")
private String id;
@Enumerated
@Extension(vendorName="datanucleus", key="gae.parent-pk",
value="true")
private String parentId;
@Enumerated
private ContentValueType contentValueType;
@Enumerated
private Blob content;
@Enumerated
private String contentType;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getParentId() {
return parentId;
}
public void setContentValueType(ContentValueType contentValueType) {
this.contentValueType = contentValueType;
}
public ContentValueType getContentValueType() {
return contentValueType;
}
public void setContent(Blob content) {
this.content = content;
}
public Blob getContent() {
return content;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getContentType() {
return contentType;
}
}
ContentValueType.java
---------------------
import java.io.Serializable;
package abc;
public enum ContentValueType implements Serializable {
PICTURE, // content is a picture
THUMBNAIL, // content is a thumbnail
TAG_DATA // tag data
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---