Hi All,


I'm trying to use the one-to-many relation with heritance but without

success. Let me explain.


I have 3 classes :


@PersistenceCapable

@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)

   public abstract class Op {

   @PrimaryKey

   @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)

   public Key key;


   @Persistent(mappedBy = "op")

   @Element(dependent = "true")

   private ArrayList<Entry> entryArr = new ArrayList<Entry>();

}


@PersistenceCapable

public class ExtendedOp extends Op {

   public double quota;

}


@PersistenceCapable

public class Entry {

@PrimaryKey

@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)

public Key key;


@Persistent

   private Op op = null;

}


When I persist, I use this code :

ExtendedOp op = new ExtendedOp();

op.addNewEntry(new Entry());

op.addNewEntry(new Entry());

pm.makePersistent(op);


After, I persisted, I reload the "ExtendedOp" with this :

String connectionQuery = "select from " + ExtendedOp.class.getName();

opArr = (List<ExtendedOp>) pm.newQuery(connectionQuery).execute();

    if (opArr != null) {

               for (ExtendedOp opExt : opArr) {

                   if ( opExt.getEntryArr() != null)

                       for (Entry entry : sale.getEntryArr()) {

                           System.out.println("ok"); //works!

                           if (entry.getOp() != null)

                               System.out.println("perfect"); //never

display

                       }

               }

           }


The problem is : the Entry has the field "operation" always null. This

field is from the relation one-to-many. Maybe this field is still null

because is class type is "parent" of ExtendedOp?


Could you help me to solve that problem?


Thanks you very much,


Bat

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/i_qtiXxQ4cYJ.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to