By default the kind of the datastore entity is derived from the simple name of the class, and test.test1.Test.class.getSimpleName() is the same as test.test2.Test.class.getSimpleName(). This is documented here: http://code.google.com/appengine/docs/java/datastore/dataclasses.html#Class_and_Field_Annotations
If you need to persist two classes in different packages but with the same name you can override the kind like this: @PersistenceCapable(table = "SomethingElse") public class Test { // ... } Hope this helps, Max On Fri, Jan 8, 2010 at 3:45 PM, w <windic...@gmail.com> wrote: > I have two persistable classes: test.test1.Test and test.test2.Test, > but I can't persist/query objects of these classes right. There is a > simple example shows wrong behavior: > > test.TestServlet.java: > > package test; > > import java.io.IOException; > > import javax.jdo.JDOHelper; > import javax.jdo.PersistenceManager; > import javax.jdo.PersistenceManagerFactory; > import javax.servlet.http.HttpServlet; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > > public class TestServlet extends HttpServlet { > > public void doGet(HttpServletRequest request, HttpServletResponse > response) throws IOException { > PersistenceManager pm = pmFactory.getPersistenceManager(); > pm.makePersistent(new test.test1.Test("1", "test1")); > pm.close(); > > pm = pmFactory.getPersistenceManager(); > pm.makePersistent(new test.test2.Test("1", "test2")); > pm.close(); > > pm = pmFactory.getPersistenceManager(); > response.getWriter().println("RESULT: " + pm.getObjectById > (test.test1.Test.class, "1")); > pm.close(); > } > > public static final PersistenceManagerFactory pmFactory = > JDOHelper.getPersistenceManagerFactory("transactions-optional"); > > } > > test.test1.TestServlet.java and test.test2.TestServlet.java are the > same except package name, so I missed it: > > import javax.jdo.annotations.*; > > @PersistenceCapable(identityType = IdentityType.APPLICATION) > public class Test { > > public Test(String id, String data) { > this.id = id; this.data = data; > } > > public String toString() { > return getClass().getName() + ": id=" + id + " data=" + data; > } > > @PrimaryKey > private String id; > > @Persistent > private String data; > > } > > Surprising result I got is following: > > RESULT: test.test1.Test: id=1 data=test2 > > Expected result: > > RESULT: test.test1.Test: id=1 data=test1 > > -- > 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 > google-appengine-j...@googlegroups.com. > To unsubscribe from this group, send email to > google-appengine-java+unsubscr...@googlegroups.com<google-appengine-java%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > > > >--
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.