Hey, so I can save data to app engine in an entity of type
"PersistentShift", a class I made to save shift information. I've got
2 objects I'm saving within the class. Both are Date objects. One is
startDate, one is endDate. I wanted to be able to query the server,
and have a return type of PersistentShift. In order to do this it was
recommended that I put my Persistent shift class in the Shared
package, as opposed to having one in the client package, and one in
the server package. I've done this, and got it to where I can save
data again, but now I'm getting an error when I try to query that
data. Below is the relevant code. My code compiles with no errors:

============================================================================
package com.spierce7.gwt.scheduler.client;

public class Scheduler implements EntryPoint {

        private final SchedulerServiceAsync schedulerService =
GWT.create(SchedulerService.class);
        public boolean timerSet = false;


        public void onModuleLoad() {
                //Date startDate = new Date();
                //Date endDate = new Date();
                //endDate.setHours(endDate.getHours()+1);

                //addShift(startDate, endDate);

                loadShifts();

        }

        private void loadShifts() {
                schedulerService.getShifts(new
AsyncCallback<List<PersistentShift>>() {
                        public void onFailure(Throwable error) {
                                Window.alert(error.getMessage());
                        }
                        public void onSuccess(List<PersistentShift> results) {
                                Window.alert("Shift Retrieved Successfully!");
                        }
                });
        }
}

======================================================================
package com.spierce7.gwt.scheduler.shared;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public final class PersistentShift implements IsSerializable {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        public Long id;
        @Persistent
        public Date startDate;
        @Persistent
        public Date endDate;

        public PersistentShift() {}

        public PersistentShift(Date startDate, Date endDate) {
                this.startDate = startDate;
                this.endDate = endDate;
        }

}

===============================================================
package com.spierce7.gwt.scheduler.server;

public class SchedulerServiceImpl extends RemoteServiceServlet
implements SchedulerService {
        private static final Logger LOG =
Logger.getLogger(SchedulerServiceImpl.class.getName());
        private static final PersistenceManagerFactory PMF =
JDOHelper.getPersistenceManagerFactory("transactions-optional");

        public void addShift(Date startDate, Date endDate) {
                PersistenceManager pm = getPersistenceManager();
                try {
                        pm.makePersistent(new PersistentShift(startDate, 
endDate));
                } finally {
                        pm.close();
                }
        }

        public List<PersistentShift> getShifts() {
                PersistenceManager pm = getPersistenceManager();
                List<PersistentShift> results = new 
ArrayList<PersistentShift>();

                try {
                        //Query query = pm.newQuery(PersistentShift.class);
                        //query.setFilter("");
                        //query.declareParameters("SchedulerDate startDate 
SchedulerDate
endDate");
                        //query.setOrdering("startDate");
                        Query query = pm.newQuery("SELECT * FROM 
PersistentShift");
                        results = (List<PersistentShift>) query.execute();
                } finally {
                        pm.close();
                }
                return results;
        }

        private PersistenceManager getPersistenceManager() {
                return PMF.getPersistenceManager();
        }
}

===========================================================================

My server is calling the get shifts method, and this is the error I'm
getting:

org.datanucleus.store.query.AbstractJDOQLQuery <init>: Candidate class
for JDOQL single-string query (PersistentShift) could not be resolved
PersistentShift
org.datanucleus.exceptions.ClassNotResolvedException: PersistentShift
        at org.datanucleus.util.Imports.resolveClassDeclaration(Imports.java:
194)
        at
org.datanucleus.store.query.AbstractJDOQLQuery.<init>(AbstractJDOQLQuery.java:
114)
        at
org.datanucleus.store.appengine.query.JDOQLQuery.<init>(JDOQLQuery.java:
68)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source)
...


Any help or suggestions are very welcome! Thanks!

~Scott

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to