javax.jdo.JDOUserException: CreatorExpression defined with class of sKey yet this class is not found

42 views
Skip to first unread message

1010111

unread,
Feb 21, 2010, 9:46:37 AM2/21/10
to Google App Engine
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

Ikai L (Google)

unread,
Feb 24, 2010, 8:20:18 PM2/24/10
to google-a...@googlegroups.com
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.


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
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

Martin Dvorak

unread,
Oct 6, 2011, 6:08:51 PM10/6/11
to google-a...@googlegroups.com
Ikai, let confirm you hypothesis ;) I faced the same problem with parameter having "new" prefix - renaming the parameter fixed the problem. My code before fix:
                        Query query=pm.newQuery(GaeQuestionAnswerBean.class);
query.setFilter("growKey == newGrowKey && ownerId == userId");
query.declareParameters("String newGrowKey, String userId");
oldQuestions = (List<GaeQuestionAnswerBean>)query.execute(newGrowKey, userId);
... and Exception:
  org.datanucleus.exceptions.NucleusUserException: CreatorExpression defined with class of GrowKey yet this class is not found
Reply all
Reply to author
Forward
0 new messages