I don't believe you can reuse the same classes for both GWT and JDO/JPA. I'm not sure that you would want to, as you may be exposing some details about your persistence that a rich client doesn't really need to know.
On Sun, Apr 18, 2010 at 6:19 PM, luka <[email protected]> wrote: > Hi All, > > I am trying to evaluate GAE + GWT (1.3.2) and I have some issue with > the "detach" feature of JDO-2.0. I have a simple service which return > all questions: > > public List<Question> getQuestions() { > PersistenceManager pm = PMF.get().getPersistenceManager(); > try { > Query query = pm.newQuery(Question.class); > List<Question> questions = > (List<Question>)pm.detachCopyAll((List<Question>)query.execute()); > > return questions; > } finally { > pm.close(); > } > } > > The Question entity is a "Persistent" object which defined with > detachable = "true" and has a bidirectional one to many relationship > to an Answer entity (which defined in the same way. > > Unfortunately I started getting the > "IncompatibleRemoteServiceException" from yesterday (till than all > worked well :( ). > > I browsed the forums of Google groups and tried to make some changes > to make things working like: > - Implementing from IsSerializable instead of Serializable (on > entities Question & Answer) > - Using "detachCopyAll" > > Nothing seems to make a different. > > I assume the code will work if I will create DTO for each persistent > entity although I really wish to avoid code duplication, plus that's > missing some of JDO 2.0 nicest feature > > Question Code: > -------------------- > > > @PersistenceCapable (detachable = "true") > public class Question implements IsSerializable { > > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > private Key key; > > @Persistent > private String topic; > > @Persistent > private String language; > > @Persistent > private String category; > > @Persistent > private String experience; > > @Persistent > private String difficultLevel; > > // Question details > > @Persistent > private String title; > > @Persistent > private String body; > > @Persistent > private String type; > > @Persistent > private String image; > > @Persistent(mappedBy = "question") > private List<Answer> answers; > > > // @Persistent > //private Author author; > > > // Classification properties > > public Question(){} > > public Question(String topic, String language, > String category, String experience, String > difficultLevel, > String title, String body, String type, String > image, > List<Answer> answers) { > super(); > //this.author = author; > this.topic = topic; > this.language = language; > this.category = category; > this.experience = experience; > this.difficultLevel = difficultLevel; > this.title = title; > this.body = body; > this.type = type; > this.image = image; > this.answers = answers; > } > > public Key getKey() { > return key; > } > > public void setKey(Key key) { > this.key = key; > } > > // public Author getAuthor() { > // return author; > // } > // > // public void setAuthor(Author author) { > // this.author = author; > // } > > public String getTopic() { > return topic; > } > > public void setTopic(String topic) { > this.topic = topic; > } > > public String getLanguage() { > return language; > } > > public void setLanguage(String language) { > this.language = language; > } > > public String getCategory() { > return category; > } > > public void setCategory(String category) { > this.category = category; > } > > public String getExperience() { > return experience; > } > > public void setExperience(String experience) { > this.experience = experience; > } > > public String getDifficultLevel() { > return difficultLevel; > } > > public void setDifficultLevel(String difficultLevel) { > this.difficultLevel = difficultLevel; > } > > public String getTitle() { > return title; > } > > public void setTitle(String title) { > this.title = title; > } > > public String getBody() { > return body; > } > > public void setBody(String body) { > this.body = body; > } > > public String getType() { > return type; > } > > public void setType(String type) { > this.type = type; > } > > public String getImage() { > return image; > } > > public void setImage(String image) { > this.image = image; > } > > public List<Answer> getAnswers() { > return answers; > } > > public void setAnswers(List<Answer> answers) { > this.answers = answers; > } > > > } > > > Answer Code > ------------------ > > > package com.lugo.dao; > > import javax.jdo.annotations.IdGeneratorStrategy; > import javax.jdo.annotations.PersistenceCapable; > import javax.jdo.annotations.Persistent; > import javax.jdo.annotations.PrimaryKey; > > import com.google.appengine.api.datastore.Key; > import com.google.gwt.user.client.rpc.IsSerializable; > > @PersistenceCapable (detachable = "true") > public class Answer implements IsSerializable { > > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > private Key key; > > @Persistent > private String answer; > > @Persistent > private Boolean isCorrect; > > @Persistent > private Question question; > > public Answer() { > super(); > } > > > public Answer(String answer, Boolean isCorrect, Question question) { > super(); > this.answer = answer; > this.isCorrect = isCorrect; > this.question = question; > } > > > public Key getKey() { > return key; > } > > public void setKey(Key key) { > this.key = key; > } > > public String getAnswer() { > return answer; > } > > public void setAnswer(String answer) { > this.answer = answer; > } > > public Boolean getIsCorrect() { > return isCorrect; > } > > public void setIsCorrect(Boolean isCorrect) { > this.isCorrect = isCorrect; > } > > public Question getQuestion() { > return question; > } > > public void setQuestion(Question question) { > this.question = question; > } > > > } > > > All the Best > Luk > > -- > 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]<google-appengine-java%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > > -- Ikai Lan Developer Relations, Google App Engine Twitter: http://twitter.com/ikai Delicious: http://delicious.com/ikailan ---------------- Google App Engine links: Blog: http://googleappengine.blogspot.com Twitter: http://twitter.com/app_engine Reddit: http://www.reddit.com/r/appengine -- 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.
