Hello,
I have just started working with the GAE's Java implementation and
have quicly run into problems attempting to run rather simple queries,
I am hoping I can find some clarification as to what I may be doing
wrong here. Here is the scenario:
I have two persistent JDOs: Profile, which stores a users profile
information and Event which is a "posting" that a user has created.
This represents a one-to-many relationship (users can create many
events). I have created this as and un-owned one-to-many
releationship. This is actually a one-to-zero-or-more relationship as
users are able to create a profile with out having to create a
cooresponding event.

This has been done so that I can query for events seperately from
retrieving profile information. It seems overkill to return all events
everytime I request a user profile.

Here is the Profile object:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Profile{

        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;
        @Persistent
        private Email email;
        @Persistent
        private ShortBlob password;
        @Persistent
        private Date created;
        @Persistent(mappedBy = "profile")
        private List<Location> locations;
        @Persistent
        private Blob logo;
        @Persistent
        private PhoneNumber phone;
        @Persistent
        private String phoneid;
        @Persistent
        private String twitterid;
//Followed by appropriate getters and setters.

Here is the Event Object:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Event {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key  key;
@Persistent
private Profile  author;
@Persistent
private String  title;
@Persistent
private Text  description;
@Persistent
private Location location;
@Persistent
private Date  created;
@Persistent
private Date  start;
@Persistent
private Date  end;
@Persistent
private Text  promomsg;
//followed by appropriate getters and setters.

I am attempting to perform the following steps:
1. User registers with email and a profile object is persisted. This
appears to be workign with all other fields persisted as null. I have
left the key field null as well and allowed the system to generate an
id (which appears to be workign correctly).
2. The profile object is stored in a session and a profile.jsp page is
displayed.
3. The profile.jsp calls a class which performs various queries on
behalf of the jsp. In this case a query to return the total count of
events created by the user. In this use case the correct number should
be 0 as the user has not created any events.

The method which is called is:
public Integer EventCount(Profile p)
        {
                Query query = pm.newQuery(Event.class);
                query.setFilter("author == authorParam");
                query.declareParameters("Profile authorParam");
                query.setResult("count(this)");
                int count = 0;
                try {
                  count = (Integer) query.execute(p);
                  return count;
                } finally {
                  pm.close();
                }

        }
during the execution of query.execute(p) the following exception is
thrown:
ov 5, 2009 8:37:40 PM com.google.apphosting.utils.jetty.JettyLogger
warn
WARNING: Nested in org.apache.jasper.JasperException:
javax.jdo.JDOFatalUserException: SELECT count(this) FROM
apps.youzat.server.Event WHERE author == authorParam PARAMETERS
Profile authorParam: Key of parameter value does not have a parent.
NestedThrowables:
org.datanucleus.exceptions.NucleusUserException: SELECT count(this)
FROM apps.youzat.server.Event WHERE author == authorParam PARAMETERS
Profile authorParam: Key of parameter value does not have a parent.:
javax.jdo.JDOFatalUserException: SELECT count(this) FROM
apps.youzat.server.Event WHERE author == authorParam PARAMETERS
Profile authorParam: Key of parameter value does not have a parent.
        at
org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException
(NucleusJDOHelper.java:354)
        at org.datanucleus.jdo.JDOQuery.execute(JDOQuery.java:252)
        at apps.youzat.server.EventService.EventCount(EventService.java:46)
        at org.apache.jsp.profile.Profile_jsp._jspService(Profile_jsp.java:
82)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
        at org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:324)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile
(JspServlet.java:292)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at com.google.appengine.tools.development.PrivilegedJspServlet.access
$101(PrivilegedJspServlet.java:23)
        at com.google.appengine.tools.development.PrivilegedJspServlet$2.run
(PrivilegedJspServlet.java:59)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.google.appengine.tools.development.PrivilegedJspServlet.service
(PrivilegedJspServlet.java:57)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
487)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
(ServletHandler.java:1093)
        at
com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter
(TransactionCleanupFilter.java:43)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
(ServletHandler.java:1084)
        at com.google.appengine.tools.development.StaticFileFilter.doFilter
(StaticFileFilter.java:121)
        at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
(ServletHandler.java:1084)
        at org.mortbay.jetty.servlet.ServletHandler.handle
(ServletHandler.java:360)
        at org.mortbay.jetty.security.SecurityHandler.handle
(SecurityHandler.java:216)
        at org.mortbay.jetty.servlet.SessionHandler.handle
(SessionHandler.java:181)
        at org.mortbay.jetty.handler.ContextHandler.handle
(ContextHandler.java:712)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
405)
        at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle
(DevAppEngineWebAppContext.java:54)
        at org.mortbay.jetty.handler.HandlerWrapper.handle
(HandlerWrapper.java:139)
        at com.google.appengine.tools.development.JettyContainerService
$ApiProxyHandler.handle(JettyContainerService.java:342)
        at org.mortbay.jetty.handler.HandlerWrapper.handle
(HandlerWrapper.java:139)
        at org.mortbay.jetty.Server.handle(Server.java:313)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
506)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete
(HttpConnection.java:830)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
        at org.mortbay.io.nio.SelectChannelEndPoint.run
(SelectChannelEndPoint.java:396)
        at org.mortbay.thread.BoundedThreadPool$PoolThread.run
(BoundedThreadPool.java:442)

I am at a loss for what is causign this. Can anyone help me understand
where my error in logic is here?

Thank you in advance,

Corey

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