Hi,
I am trying to create owned one-to-many entities. Class "Nemovitost" has 
exactly one "Realitka" class and "Realitka" can have many "Nemovitost".

Unfortunately I am failing to create "Nemovitost". When I do that, it seems 
ok, no exception raised during persist but no entity "Nemovitost" can be 
found in Datastore viewer and the "List<Nemovitost> seznamNemovitosti" stays 
at size 0. And there is no field "seznamNemovitosti" in Datastore viewer.

Perhaps it is something dumb but I can't find the problem. Any advice 
appreciated.
This is parts of my code:

Realitka.java:
...
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Realitka {

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

@Persistent(mappedBy="realitka")
private List<Nemovitost> seznamNemovitosti;
...

Nemovitost.java:
...
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Nemovitost {

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

@Persistent
private Realitka realitka;
...

Persisting in servlet:
...
PersistenceManager pm = PMF.get().getPersistenceManager();
Transaction tx = pm.currentTransaction();
Nemovitost n = new Nemovitost(req.getParameter("value"));
tx.begin();
Realitka r = pm.getObjectById(Realitka.class, rkId); *//Realitka was 
previously created and is fetched correctly here.*
n.setRealitka(r);
try {
            n = pm.makePersistent(n); *//No exception here, but no 
Nemovitost in Datastore is created :(*
        } finally {
            tx.commit();
            pm.close();
        }
...

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