Hello there!
I have the following owned many to one relationship defined, a project
has many files and files belongs to one and only one project (the code
is below). Nevertheless, i cant save any relationships, i've managed
to save files and projects but no relationships between them and if
check the dataviewer in the dashboard there is no column "project" for
the entity "PersistentFile", however there is one column that (i
think) serves the purpose of mantaining the order of the child object
in the father's child list ("files_INTEGER_IDX").
This is how i save:
PersistenceManager pm = PMF.get().getPersistenceManager();
try{
persistentProject = new PersistentProject("proyecto1");
persistentProject.addFile(new
PersistentFile("archivo1.txt"));
persistentProject.addFile(new
PersistentFile("archivo2.txt"));
persistentProject.addFile(new
PersistentFile("archivo3.txt"));
pm.makePersistent(persistentProject);
}
finally{
pm.close();
}
These are the class definitions:
@PersistenceCapable
public class PersistentProject{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String name;
@Persistent(mappedBy = "project")
private List<PersistentFile> files;
public PersistentProject(String name){
this.name = name;
this.files = new Vector<PersistentFile>();
}
/**
* @return the key
*/
public Key getKey() {
return key;
}
/**
* @param key the key to set
*/
public void setKey(Key key) {
this.key = key;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the files
*/
public List<PersistentFile> getFiles() {
return files;
}
/**
* @param files the files to set
*/
public void setFiles(List<PersistentFile> files) {
this.files = files;
}
public void addFile(PersistentFile file){
files.add(file);
}
}
@PersistenceCapable
public class PersistentFile{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String name;
@Persistent
private PersistentProject project;
public PersistentFile(String name){
this.name = name;
}
/**
* @return the key
*/
public Key getKey() {
return key;
}
/**
* @param key the key to set
*/
public void setKey(Key key) {
this.key = key;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the project
*/
public PersistentProject getProject() {
return project;
}
/**
* @param project the project to set
*/
public void setProject(PersistentProject project) {
this.project = project;
}
}
cheers! thanks in advance!
Rafael
PS: I know there are a lot of similar posts but so far i have not
found one that can help me
--
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.