Up until recently, using abstract classes and persistent subclasses usually failed to work, but the latest preview release for the JDO/JPA layer includes support for inheritance. More information here:
http://groups.google.com/group/google-appengine-java/browse_thread/thread/c4208f960d05d11a - Jason On Tue, Oct 27, 2009 at 11:16 AM, RSN <romeo.sanc...@gmail.com> wrote: > > Hi, > > I am new to AppEngine, and I am getting an exception when I try to > initialize a persistent class. > > First, I have two questions: > > 1) Can we use abstract classes for persistent objects? My code looks > very simple: > > @PersistenceCapable(identityType = IdentityType.APPLICATION) > public class StudentImpl extends StudentAbstract implements Student { > @Persistent > private String name; > > public StudentImpl(Key studentKey, String name){ > super(studentKey); > this.name = name; > } > > .....etc, etc > } > > Notice that the primary Key is held in the abstract super class. Is > this ok? > > @PersistenceCapable(identityType = IdentityType.APPLICATION) > public abstract class StudentAbstract{ > > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > private Key objectKey; > public StudentAbstract(Key objectId){ > this.objectKey = objectId; > } > ......etc, etc > } > > Is this design feasible? > > 2) If my declarations are correct, then Why do I get the following > exception when I try to create an object. > > Caused by: java.lang.NoSuchMethodError: > > edu.isi.tie21.star.server.db.objects.STARDBObjectAbstract.jdoGetManagedFieldCount > ()I > at > > edu.isi.tie21.star.server.db.objects.StudentImpl.__jdoGetInheritedFieldCount > (StudentImpl.java) > at edu.isi.tie21.star.server.db.objects.StudentImpl.<clinit> > (StudentImpl.java) > at edu.isi.tie21.star.server.StudentServiceImpl.addStudent > (StudentServiceImpl.java:150) > > The code that generates the error is: > pm.makePersistent( > new StudentImpl( > > KeyFactory.createKey( > > StudentImpl.class.getSimpleName(), s.getName()), > > s.getName())); > > I have searched the web, and it seems the error is related to the way > the VM initializes objects with super classes (in my case I have an > abstract class). The problem is that the VM is trying to access the > abstract class with the jdoGetManagedFieldCount() method before it is > created. is this really the problem? Is there a way around it? > > Thanks a lot, I appreciate any help on this issue. > > RSN > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 google-appengine-java@googlegroups.com To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en -~----------~----~----~----~------~----~------~--~---