I wonder if something strange is happening where it thinks newsKey is you trying to say "new sKey". What happens if you rename the primary key?
At any rate, you can just use pm.getObjectById(key) to do a single entity retrieval. On Sun, Feb 21, 2010 at 6:46 AM, 1010111 <[email protected]> wrote: > Hi, > > I am trying to develop an app in java on App Engine, but i getting > this annoying error over and over, i couldn't find the solution > anywhere in google's search engine. > > Here is what i make: > 1. I use eclipse and created a class name News.java > > ====================================================== > package ultra.robot.wars.omega; > > import java.util.Date; > > import javax.jdo.annotations.IdGeneratorStrategy; > import javax.jdo.annotations.IdentityType; > import javax.jdo.annotations.PersistenceCapable; > import javax.jdo.annotations.Persistent; > import javax.jdo.annotations.PrimaryKey; > > import com.google.appengine.api.users.User; > > @PersistenceCapable(identityType = IdentityType.APPLICATION) > public class News { > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > private Long newsKey; > > @Persistent > private User author; > > @Persistent > private String newsTitle; > > @Persistent > private String newsContent; > > @Persistent > private String newsImagePath; > > @Persistent > private Date date; > > @Persistent > private int version; > > public News(User author, String nTitle, String nContent, String > nImagePath, Date date, int version){ > this.author = author; > this.newsTitle = nTitle; > this.newsContent = nContent; > this.newsImagePath = nImagePath; > this.date = date; > this.version = version; > } > > public User getAuthor(){ > return author; > } > > public String getNewsTitle(){ > return newsTitle; > } > > public String getNewsContent(){ > return newsContent; > } > > public String getNewsImagePath(){ > return newsImagePath; > } > > public Long getNewsKey(){ > return newsKey; > } > > public Date getDate(){ > return date; > } > > public int getVersion(){ > return version; > } > > public void setAuthor(User usr){ > this.author = usr; > } > > public void setNewsTitle(String nTitle){ > this.newsTitle = nTitle; > } > > public void setNewsContent(String nContent){ > this.newsContent = nContent; > } > > public void setNewsImagePath(String nImagePath){ > this.newsImagePath = nImagePath; > } > > public void setDate(Date date) { > this.date = date; > } > > public void setVersion(int version) { > this.version = version; > } > } > ============================================================ > > 2. When i query it from jsp like this: > > =================================================================================== > PersistenceManager pm2 = PMF.get().getPersistenceManager(); > String query2 = "select from " + News.class.getName() + " where > newsKey == " + newskey; > List<News> news2 = (List<News>) pm2.newQuery(query2).execute(); > > =================================================================================== > > then it always give me the error javax.jdo.JDOUserException: > CreatorExpression defined with class of sKey yet this class is not > found, i notice that the sKey is the substring of newsKey in the where > clause, i don't know why it think sKey is a class, but if the query > didn't include where clause, it didn't give such error > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-appengine%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. > > -- Ikai Lan Developer Programs Engineer, Google App Engine http://googleappengine.blogspot.com | http://twitter.com/app_engine -- You received this message because you are subscribed to the Google Groups "Google App Engine" 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?hl=en.
