Unable to create entity on Google App Engine Datastore

339 views
Skip to first unread message

ani

unread,
Feb 26, 2012, 4:24:18 AM2/26/12
to Google App Engine
Hello, I’m trying to connect an android application with Google app
engine. I am using Google App Engine Datastore as my “database”. The
problem is that I am having difficulties in building entities on the
GAE datastore.

I’m using JDO to create my entity and I am following the same code
pattern as on code.google.com
(http://code.google.com/appengine/docs/java/datastore/jdo/
dataclasses.html).

The whole thing runs without error but when I open it on Datastore
viewer at http://localhost:8888/_ah/admin, where I’m suppose to see
all my entities, none of them are being displayed. Instead I’m
receiving the following message:
“Datastore has no entities in the Empty namespace. You need to add
data programmatically before you can use this tool to view and edit
it.”

I even tried to store a simple data object in the datastore for the
entity I created, but it does not work, so I am confusing whether the
entity has been created or not.
(http://code.google.com/appengine/docs/java/datastore/jdo/
creatinggettinganddeletingdata.html)

Below is my Entity Category

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;


@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Category{

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
Long id;
@Persistent
private String ccode;
@Persistent
private String cname;

public Category(String ccode, String cname){
this.ccode = ccode;
this.cname = cname;
}

public Long getID() {
return id;
}
public void setID(Long id) {
this.id = id;
}
public String getCcode() {
return ccode;
}
public void setCode(String ccode) {
this.ccode = ccode;
}
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname;
}

}

Here i"m trying to add an object data in Entity category

Class PMF
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.PersistenceManager;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import our.fy.project.Category;

public final class PMF {
private static final PersistenceManagerFactory pmfInstance =
JDOHelper.getPersistenceManagerFactory("transactions-
optional");
private PMF() {}
public static PersistenceManagerFactory
getPersistenceManagerFactory() {
return pmfInstance;
}
public void addCategory(Category c) {
PersistenceManager pm =
getPersistenceManagerFactory().getPersistenceManager();
c = new Category("abc","xyz");
Key key =
KeyFactory.createKey(Category.class.getSimpleName(), "011");

c.setKey(key);

try {
pm.makePersistent(c);
} finally {
pm.close();
}
}


Can anyone help, whether I am missing something or not? Thanks.

Robert Kluin

unread,
Mar 1, 2012, 2:18:54 PM3/1/12
to google-a...@googlegroups.com
Are you making requests against your local server, or the app running
on appspot?

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

Anand Moorthy

unread,
Jun 20, 2015, 2:05:43 PM6/20/15
to google-a...@googlegroups.com
Is this sorted ? Same problem here too :(

Nick (Cloud Platform Support)

unread,
Jun 22, 2015, 12:45:43 PM6/22/15
to google-a...@googlegroups.com, Anand Moorthy
Hi All,

OP's original issue appears to be related to devserver/production datastore locations, but it's impossible to tell without more detailed troubleshooting. Anand, as to your question, it's even more impossible to tell whether your issue truly is related to that of OP.

What's needed for anybody who would want to report an issue, is to use the public issue tracker rather than google groups. This forum is meant for general discussion of the platform, not specific technical issues.

If you believe that what you've encountered is not a platform issue but rather a problem with how you've configured your code, although you're not sure what it may be specifically, you should post to stackoverflow.

In either case, posting an issue so that other users can help requires very thorough explanation of what you're doing and what's going wrong before the people on the other side of the internet will be able to understand and debug your issue.

I wish you the best of luck in proceeding to either open a proper issue report in the public issue tracker, or posting to stackoverflow so that you can get support from the community of developers.
Reply all
Reply to author
Forward
0 new messages