If its an owned relationship, then if I'm not mistaken both classes (parent
and child) must have a Key class id, and cannot have a Long id, see this
excerpt from 
docs<http://code.google.com/appengine/docs/java/datastore/relationships.html>
:

"The child class must have a key field whose type can contain the parent key
information: either a Key, or a Key value encoded as a string. See Creating
Data: 
Keys<http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Keys>
for
information on key field types."

Hope this helps,

Yaniv Kessler

On Tue, Jun 22, 2010 at 7:30 AM, Moretto <[email protected]> wrote:

> Hi,
>
> I want to create a relationship one to many with jdo on my entity.
> Actually, the following code throws an exception.
> As you can see i had to comment the code that throws a runtime
> exception.
>
>
> package com.appspot.malacma.entity;
>
> import java.util.ArrayList;
> import java.util.Date;
> import java.util.List;
> import javax.jdo.annotations.*;
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> public class Context {
>
>    @PrimaryKey
>    @Persistent(valueStrategy = IdGeneratorStrategy.SEQUENCE)
>    private Long id;
>    @Persistent
>    private String domain;
>    @Persistent
>    private String description;
>    @Persistent
>    private Date createdAt;
>    @Persistent
>    private String url;
>    @Persistent
>    private String contextName;
>    @Persistent
>    private String waveID;
>    @Persistent
>    private String creator;
>    @Persistent
>    private String language;
>    @Persistent
>    private Visibility visibility = Visibility.PRIVATE;
>    @Persistent
>    private Status status = Status.DEFAULT;
> //    @Element(dependent = "true")
> //    @Persistent(mappedBy = "context")
> //    private List<RequirementModule> requirementsModule;
> //    @Element(dependent = "true")
> //    @Persistent(mappedBy = "context")
> //    private List<Repository> repositoryList;
> //    @Element(dependent = "true")
> //    @Persistent(mappedBy = "context")
> //    private List<Tag> tag;
>
>    public Context() {
> //        this.repositoryList = new ArrayList<Repository>();
> //        this.requirementsModule = new
> ArrayList<RequirementModule>();
> //        this.tag = new ArrayList<Tag>();
>        this.visibility = Visibility.PRIVATE;
>        this.status = Status.DEFAULT;
>    }
>
>
>
>    public String getCreator() {
>        return creator;
>    }
>
>    public void setCreator(String creator) {
>        this.creator = creator;
>    }
>
>    public String getContextName() {
>        return contextName;
>    }
>
>    public void setContextName(String contextName) {
>        this.contextName = contextName;
>    }
>
>    public Date getCreatedAt() {
>        return createdAt;
>    }
>
>    public void setCreatedAt(Date createdAt) {
>        this.createdAt = createdAt;
>    }
>
>    public String getDescription() {
>        return description;
>    }
>
>    public void setDescription(String description) {
>        this.description = description;
>    }
>
>    public String getDomain() {
>        return domain;
>    }
>
>    public void setDomain(String domain) {
>        this.domain = domain;
>    }
>
>    public Long getId() {
>        return id;
>    }
>
>    public void setId(Long id) {
>        this.id = id;
>    }
>
>    public String getUrl() {
>        return url;
>    }
>
>    public void setUrl(String url) {
>        this.url = url;
>    }
>
>    public String getWaveID() {
>        return waveID;
>    }
>
>    public void setWaveID(String waveID) {
>        this.waveID = waveID;
>    }
>
>    public String getLanguage() {
>        return language;
>    }
>
>    public void setLanguage(String language) {
>        this.language = language;
>    }
>
>    public Status getStatus() {
>        return status;
>    }
>
>    public void setStatus(Status status) {
>        this.status = status;
>    }
>
>    public Visibility getVisibility() {
>        return visibility;
>    }
>
>    public void setVisibility(Visibility visibility) {
>        this.visibility = visibility;
>    }
>
>    @Override
>    public boolean equals(Object obj) {
>        if (obj == null) {
>            return false;
>        }
>        if (getClass() != obj.getClass()) {
>            return false;
>        }
>        final Context other = (Context) obj;
>        if (this.id != other.id && (this.id == null || !
> this.id.equals(other.id))) {
>            return false;
>        }
>        if ((this.domain == null) ? (other.domain != null) : !
> this.domain.equals(other.domain)) {
>            return false;
>        }
>        if ((this.url == null) ? (other.url != null) : !
> this.url.equals(other.url)) {
>            return false;
>        }
>        if ((this.waveID == null) ? (other.waveID != null) : !
> this.waveID.equals(other.waveID)) {
>            return false;
>        }
>        return true;
>    }
>
>    @Override
>    public int hashCode() {
>        int hash = 7;
>        hash = 13 * hash + (this.id != null ? this.id.hashCode() : 0);
>        hash = 13 * hash + (this.domain != null ?
> this.domain.hashCode() : 0);
>        hash = 13 * hash + (this.url != null ? this.url.hashCode() :
> 0);
>        hash = 13 * hash + (this.waveID != null ?
> this.waveID.hashCode() : 0);
>        return hash;
>    }
>
>    @Override
>    public String toString() {
>        return "Context{" + "id=" + id + "domain=" + domain +
> "description=" + description + "createdAt=" + createdAt + "url=" + url
> + "contextName=" + contextName + "waveID=" + waveID + '}';
>    }
>
> //    public List<Repository> getRepositoryList() {
> //        return repositoryList;
> //    }
> //
> //    public void setRepositoryList(List<Repository> repositoryList) {
> //        this.repositoryList = repositoryList;
> //    }
> //
> //    public List<RequirementModule> getRequirementsModule() {
> //        return requirementsModule;
> //    }
> //
> //    public void setRequirementsModule(List<RequirementModule>
> requirementsModule) {
> //        this.requirementsModule = requirementsModule;
> //    }
>
> //    public List<Tag> getTag() {
> //        return tag;
> //    }
> //
> //    public void setTag(List<Tag> tag) {
> //        this.tag = tag;
> //    }
>
>
> }
>
>
> Any ideia?
>
> --
> 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]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>

-- 
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