Re: [appengine-java] Regarding Datastore

2010-06-30 Thread Ikai L (Google)
Yes, you can query using the low level API for a list of Keys, then call
delete with that List. I'll be expanding my blog post series about the
low-level API sometime soon.

On Fri, Jun 25, 2010 at 4:28 AM, MANISH DHIMAN manisd...@gmail.com wrote:

 Hi All
 I have the following queries.

 -- I inserted a new entity (but do not commit the transaction) into
 the data store and then count the total number of entities in the data
 store. There is no change in the count of entities from the previous
 one. I think for that particular transaction it should be incremented
 by one i.e. for a user that insert new record into table it should be
 visible to that user even when transaction is not committed.
  Sample code:
 DatastoreService datastoreService =
 DatastoreServiceFactory.getDatastoreService();
Transaction transaction =
 datastoreService.beginTransaction();
String employee = Employee;
Query query = new Query(employee);
PreparedQuery preparedQuery =
 datastoreService.prepare(query);
int totalEntities = preparedQuery.countEntities();
response.getWriter().print(Total Row in DataSource before
 insertion:  + totalEntities + br);
Key key = KeyFactory.createKey(employee, 99656994);
Entity entity = new Entity(employee, key);
entity.setProperty(Name, ABCD);
entity.setProperty(Village, ASDF);
entity.setProperty(Designation, Constable);
datastoreService.put(entity);
totalEntities = preparedQuery.countEntities();
response.getWriter().print(Total Row After Insertion :  +
 totalEntities + br);
preparedQuery = datastoreService.prepare(query);
response.getWriter().print(Total Row After Insertion after
 reInitilization:  + totalEntities + br);
transaction.commit();

 -- Is it possible to delete an entity from table using low level api
 without providing any Kay object(On the basis of filter other than
 Key).

 --I am not able to apply filter on Key of an entity.

 --

 --
 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.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.




-- 
Ikai Lan
Developer Programs Engineer, Google App Engine
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 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.



[appengine-java] Regarding Datastore

2010-06-25 Thread MANISH DHIMAN
Hi All
I have the following queries.

-- I inserted a new entity (but do not commit the transaction) into
the data store and then count the total number of entities in the data
store. There is no change in the count of entities from the previous
one. I think for that particular transaction it should be incremented
by one i.e. for a user that insert new record into table it should be
visible to that user even when transaction is not committed.
 Sample code:
 DatastoreService datastoreService =
DatastoreServiceFactory.getDatastoreService();
Transaction transaction = datastoreService.beginTransaction();
String employee = Employee;
Query query = new Query(employee);
PreparedQuery preparedQuery = datastoreService.prepare(query);
int totalEntities = preparedQuery.countEntities();
response.getWriter().print(Total Row in DataSource before
insertion:  + totalEntities + br);
Key key = KeyFactory.createKey(employee, 99656994);
Entity entity = new Entity(employee, key);
entity.setProperty(Name, ABCD);
entity.setProperty(Village, ASDF);
entity.setProperty(Designation, Constable);
datastoreService.put(entity);
totalEntities = preparedQuery.countEntities();
response.getWriter().print(Total Row After Insertion :  +
totalEntities + br);
preparedQuery = datastoreService.prepare(query);
response.getWriter().print(Total Row After Insertion after
reInitilization:  + totalEntities + br);
transaction.commit();

-- Is it possible to delete an entity from table using low level api
without providing any Kay object(On the basis of filter other than
Key).

--I am not able to apply filter on Key of an entity.

--

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