Re: [appengine-java] Where is the datastore file on windows?

2010-06-13 Thread Chau Huynh
It's located at Eclipse workspace\Your
app\war\WEB-INF\appengine-generated ...

On Sun, Jun 13, 2010 at 3:25 PM, quqtalk quqt...@gmail.com wrote:

 Use below Java code:
private static final PersistenceManagerFactory pmfInstance =
 JDOHelper.getPersistenceManagerFactory(transactions-optional);
Category c1 = new Category();
c1.setCategoryId(FISH);
c1.setDescription(image src=\../images/fish_icon.gif\font
 size=\5\ color=\blue\ Fish/font);
c1.setName(FISH);
pm.makePersistent(c1);
 Run it as Google Web Application in Eclipse on Windows.
 I think the App Engine persistent the data to the disk, any one know
 where is it? Or am I wrong?

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



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



Re: [appengine-java] Records Count

2010-06-12 Thread Chau Huynh
Can you please try:
select count (this) from entity?
This topic was discussed once or more in the group...

On Fri, Jun 11, 2010 at 5:39 PM, RAVINDER MAAN rsmaan...@gmail.com wrote:

 How can we get records count for a query in JDO.
 In sql we have select count(*) from table_name
 i want to get number of records returned by a query. what is the
 efficient way to do that.One option is to use size() function .I think
 it is not best way.

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



-- 
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] Re: Server Error A server error has occurred. - Whilst Deleting app version.

2010-06-06 Thread Chau
Hello Ikai,

Can you please include my app in deleting batch as well:
app id: gaepocdemo
version: 3

Thank you

On Apr 10, 5:47 am, Ikai L (Google) ika...@google.com wrote:
 We'll scrub these next time we do them in batch. For the time being - it's
 annoying that it's stuck there, but we allocate you 100 versions, so this
 shouldn't get in your way.



 On Wed, Apr 7, 2010 at 2:47 PM, Eurig Jones eurigjo...@gmail.com wrote:
  mailmymove - version 1
 http://www.mailmymove.com

  On Apr 5, 9:51 pm, Ikai L (Google) ika...@google.com wrote:
   What's your application ID and the version you are trying to delete?

   On Mon, Apr 5, 2010 at 11:20 AM, Eurig Jones eurigjo...@gmail.com
  wrote:
Hi,

I'm getting a...

Server Error

A server error has occurred.

Whilst trying to delete a particular version of an app. For the others
it's no problem, but this particular version I cannot delete and I'm
getting the Server error. Can anyone suggest what I can do about this?
(Or where to report it at least)

--
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
  google-appengine-java%2bunsubscr...@googlegroups.comgoogle-appengine-java%252bunsubscr...@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 Enginehttp://
  googleappengine.blogspot.com|http://twitter.com/app_engine

  --
  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 
 Enginehttp://googleappengine.blogspot.com|http://twitter.com/app_engine

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



Re: [appengine-java] Re: Transaction exception when not using a transaction ?

2010-06-04 Thread Chau Huynh
Did you have different entity groups inside a transaction?
Google have a constraint of what can be done in a transaction here
http://code.google.com/appengine/docs/python/datastore/transactions.html#What_Can_Be_Done_In_a_Transaction


On Fri, Jun 4, 2010 at 5:45 PM, JD liva...@gmail.com wrote:

 After debugging, I was able to get rid of the exception by removing a
 pm.newQuery() which was happening on a different entity group.

 To me this is a bug in App Engine, as there is no reason the query on
 a particular entity group should fail outside a transaction.

 On Jun 3, 12:25 pm, Millisecond millisec...@gmail.com wrote:
  Hmmm.
 
  How is your object model structured?  Do entities have other entities
  as direct references?
 
  If you have class A { B b } and setting b to an instance of B that
  already existed might throw the error you're seeing.
 
  I changed my structure to be class A { String bKey } for a variety
  of other reasons, but guess it also may have gotten around this
  problem.
 
  Alternatively, post as much code as you can and I'll see if anything
  else rings a bell, early on I spent a frustrated day or two working
  around this exception in a variety of places so know it can be
  frustrating.
 
  -C
 
  On Jun 3, 6:33 am, JD liva...@gmail.com wrote:
 
   I added a call to flush() after every change on the PM-managed object,
   but that did not help.
 
   Also doing a pm.flush() does not throw this exception, but doing a
   pm.close() does - which seems to be contrary to your reasoning (I
   would expect flush to throw the same exception if multiple entity
   groups were at cause).
 
   On Jun 3, 1:33 am, Millisecond millisec...@gmail.com wrote:
 
Even though you're not using transactions, I think it's trying to
 make
the .close() call atomic (maybe with an internal implicit
transaction), failing or succeeding as a whole.  And as I understand
it, entities not in the same group can be stored on separate machines
so can't be operated on atomically.
 
I've worked around this by calling a flush() after most any change on
a PM-managed object until close().  If this has a huge number of
 reqs/
s, you may want to re-architect to get the objects in the same entity
group as multiple flushes won't be very efficient.
 
-C
 
On Jun 2, 8:26 pm, JD liva...@gmail.com wrote:
 
 I have a PersistenceManager
 
 PersistenceManager pm = PMF.get().getPersistenceManager();
 
 which I use to do a bunch of operations on different objects, but
 WITHOUT transaction (run queries, store entities and lookup
 entities).
 
 I then close the manager with pm.close() and get this obscure error
 that complains about multiple entity groups inside a transaction
 even
 though I am not using a transaction (you will notice that the error
 is
 not the usual one where it prints the different entity groups).
 
 I am not 100% confident but have the impression that this error
 started happening with the 1.3.4 release.
 100% reproducible use case. Would appreciate input from App Engine
 developers.
 
 com.myapp.servlet.task.PopulateUserPages doAction: Illegal argument
 javax.jdo.JDOFatalUserException: Illegal argument
 at

 org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(Nuc
 leusJDOHelper.java:
 344)
 at

 org.datanucleus.jdo.JDOPersistenceManager.close(JDOPersistenceManager.java:
 281)
 at
 com.myapp.dao.jdo.DatastoreService.release(DatastoreService.java:
 631)
 at

 com.myapp.servlet.AbstractBaseServlet.releaseService(AbstractBaseServlet.ja
 va:
 243)
 at

 com.myapp.servlet.task.PopulateUserPages.doAction(PopulateUserPages.java:
 132)
 at
 com.myapp.servlet.task.Dispatcher.doAction(Dispatcher.java:35)
 at
 com.myapp.servlet.task.TaskServlet.doAction(TaskServlet.java:36)
 at

 com.myapp.servlet.AbstractBaseServlet.doGenericAction(AbstractBaseServlet.j
 ava:
 194)
 at

 com.myapp.servlet.AbstractBaseServlet.doPost(AbstractBaseServlet.java:
 84)
 at
 javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
 at
 javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
 at
 org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
 511)
 at org.mortbay.jetty.servlet.ServletHandler
 $CachedChain.doFilter(ServletHandler.java:1166)
 at

 com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlo
 bUploadFilter.java:
 97)
 at org.mortbay.jetty.servlet.ServletHandler
 $CachedChain.doFilter(ServletHandler.java:1157)
 at

 com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionF
 ilter.java:
 35)
 at org.mortbay.jetty.servlet.ServletHandler
 

[appengine-java] Re: Delete error version

2010-06-04 Thread Chau
Hello Google,

I've just tried to delete the error version again and still no luck.
The same issue report: Server Error. A server error has occurred.
Can you help me delete this version 3.

Thanks

On May 27, 12:41 am, Chau Huynh cmhu...@gmail.com wrote:
 Hello Google,

 Can you please help me to delete an error version in my app?
 When I tried to delete it, the system reported
 Server Error. A server error has occurred.

 My app id: gaepocdemo
 Error version: 3

 Thanks

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



Re: [appengine-java] How to use Key as filter

2010-05-31 Thread Chau Huynh
Check this out
http://gae-java-persistence.blogspot.com/2010/01/querying-with-key-parameters.html
Key is special datatype and you will need to use help API by Google to
re-create the key before passing it in.

On Sun, May 30, 2010 at 9:47 PM, Dormand mfjhs...@gmail.com wrote:

 Hi, I have a persistance class. now i want to query with its key and
 other one field.
 I have tried in this waya

 Query qry2 = pm.newQuery(File.class);
 qry2.setFilter(key == keyParam);
 qry2.setFilter(initialVersion = version);
 qry2.declareParameters(com.google.appengine.api.datastore.Key
 keyParam, long version);

 fileList = (ListFile) qry2.execute(key, version);

 but it do not show any result

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



-- 
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] Delete error version

2010-05-26 Thread Chau Huynh
Hello Google,

Can you please help me to delete an error version in my app?
When I tried to delete it, the system reported
Server Error. A server error has occurred.

My app id: gaepocdemo
Error version: 3

Thanks

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



Re: [appengine-java] Re: AppEngine gets very slow when not used for some time

2010-05-24 Thread Chau Huynh
Hi Rahul,

About loading request/performance, there're lots of discussions that you can
find in the groups, please just try google it.

Here are some notes based on reading those.
Latency causes by
1- time to start new JVM
2- time to load your application

To reduce load time by 1) others star request to
a) pay to reserve JVM
b) request Google to load your app before start dispatch request to that
instance
c) accept the situation

For 2) we try to
a- try to use/replace frameworks with light-weight ones: datastore access
framework, MVC framework,...
b- try to limit calculation in your index page to alleviate the impact of
loading request
c- design your object model based on your need, so that you do calculation
at insert time, not at query time. For example, in my app, if I want to
report on year and quarter, then I have 5 summary record for those,
instead of querying and computing those
d- caching result. For example, If I know 1 one 5 piece of data above would
be read frequently, then I will read those 5 all, and put into memcache for
later use
...

So it's application-specific, I don't know if each of above can help you.
But only you who can know if which one of your code can be cached and how...

HTH

On Sun, May 23, 2010 at 11:37 AM, Rahul rahul.jun...@gmail.com wrote:

 Chau,

 Thanks for pointing to the link. I did go through the link and i
 think, what i thought was right.
 Also i was going through the following point in the section you
 provided : How can I speed up loading requests?  and the second
 point mentioned is Share expensive initialization between JVMs. For
 example, put data which is expensive to read or compute into memcache,
 where it can be quickly read by other JVMs during startup. so in this
 scenario where do you load this memcache so that it can be shared
 between the jvm instances.

 Any pointers or clues highly appreciated.

 Thanks,
 Rahul

 On May 22, 10:51 pm, Chau Huynh cmhu...@gmail.com wrote:
  It seems like loading request...
 http://code.google.com/appengine/kb/java.html#What_Is_A_Loading_Request
 
 
 
  On Sun, May 23, 2010 at 4:55 AM, Rahul rahul.jun...@gmail.com wrote:
   I have an application running on appengine and no doubt it works
   great. but when the application is not used for some time. it goes
   very slow.
   Suppose i don;t use the application for around 5 hours or so, then
   next time when i try to use it, the response is very slow. Is there
   any thing specific which i am missing in adding application to
   appengine.
 
   Any clues are pointers are highly appreciated.
 
   Thanks,
   Rahul
 
   --
   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
 google-appengine-java%2bunsubscr...@googlegroups.comgoogle-appengine-java%252bunsubscr...@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.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group athttp://
 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.comgoogle-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.



Re: [appengine-java] AppEngine gets very slow when not used for some time

2010-05-22 Thread Chau Huynh
It seems like loading request...
http://code.google.com/appengine/kb/java.html#What_Is_A_Loading_Request

On Sun, May 23, 2010 at 4:55 AM, Rahul rahul.jun...@gmail.com wrote:

 I have an application running on appengine and no doubt it works
 great. but when the application is not used for some time. it goes
 very slow.
 Suppose i don;t use the application for around 5 hours or so, then
 next time when i try to use it, the response is very slow. Is there
 any thing specific which i am missing in adding application to
 appengine.

 Any clues are pointers are highly appreciated.

 Thanks,
 Rahul

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



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



Re: [appengine-java] appengine unaware code!

2010-05-21 Thread Chau Huynh
You can take a look on 4 types of key on app engine and choose what you
want:
http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Keys

On Sat, May 22, 2010 at 5:35 AM, aijazzz aija...@gmail.com wrote:

 Hi,
 I was looking to some examples to start my work on google appengine
 application and found out that I have to use appengine related code in
 source. For example, in a database example I found this,
 import com.google.appengine.api.datastore.Key;

 I am wondering if there is a way I can keep my code clean so that I
 can use same code in another environment?
 Please suggest. Thanks.

 regards,
 Ijaz

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



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



Re: [appengine-java] delete the entries in the datastore

2010-05-21 Thread Chau Huynh
Have you tried searching the groups, this topic was discussed in detail with
experience shared..
http://groups.google.com/group/google-appengine-java/search?group=google-appengine-javaq=delete+all+entitiesqt_g=Search+this+group

In summary, advise from the group is to use Task Queue to work on mass
volume data.

On Sat, May 22, 2010 at 7:41 AM, drift elysium drift2elys...@gmail.comwrote:

 Hi all,


 Is there a way to delete all the entries in the datastore after deploying
 the application to the app engine?

 Thanks

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


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



Re: [appengine-java] Re: Persistent Identity of JPA Entities

2010-05-19 Thread Chau Huynh
I just wonder if you need an unique ID only, then you can let Google do it
for you (sorry if this interrupted your discussion)
http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/DatastoreService.html#allocateIds%28com.google.appengine.api.datastore.Key,%20java.lang.String,%20long%29

On Thu, May 20, 2010 at 11:45 AM, Luca luca.mas...@gmail.com wrote:

 Some more infos.

 The behavious of DataNucleus depends on the strategy I choose to
 generate the @Id field.

 When I use GAE I always use the GenerationType.IDENTITY because I read
 that on JDO docs (http://code.google.com/appengine/docs/java/datastore/
 dataclasses.htmlhttp://code.google.com/appengine/docs/java/datastore/%0Adataclasses.html:
  Primary keys of type Key require a @PrimaryKey
 annotation and a @Persistent(valueStrategy =
 IdGeneratorStrategy.IDENTITY) annotation) and I saw that GAE
 documentation about JDO is usually more deep that JPA documentation.

 But If I choose GenerationType.AUTO then I see that also DataNucleus,
 like all the other persistence provider, generate the key after the
 persist and before the flush/commit. Very strange indeed because for
 H2 DataBase the AUTO should choose IDENTITY generation.

 I'm still more convinced this is a bug in DataNucleus that affect the
 way we work on Google App Engine.

 On 19 Mag, 07:26, datanucleus andy_jeffer...@yahoo.com wrote:
  I've already asked you twice to post your class. You haven't. That
  provides no context for any comment, and I've already told you why
  datastore operations are delayed until commit/flush. Why do you think
  there's a flush() method if you think things ought to go straight to
  the datastore ?
 
  JPA2 spec page 29 footnote 12.
  spec[12] If the application does not set the primary key attribute
  corresponding to the relationship, the value of that attribute may not
  be available until after the entity has been flushed to the database./
  spec
 
  spec/**
  * Synchronize the persistence context to the underlying database.
  * @throws PersistenceException if the flush fails
  */
  public void flush();/spec
 
  spec• If X is a new entity, it becomes managed. The entity X will be
  entered into the database at or
  before transaction commit or as a result of the flush operation./
  spec
 
  http://www.datanucleus.org/products/accessplatform/jpa/transaction_ty...
 
  End.
 
  --
  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 athttp://
 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.comgoogle-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.



Re: [appengine-java] DateTime Comparison

2010-05-07 Thread Chau Huynh
Can you please try declare the date parameter and let the library help you
pass it in?
WHERE date  :date
query.setParameter(date, date);

On Fri, May 7, 2010 at 12:19 PM, CodeMan chinu...@yahoo.com wrote:

 Hi,
 I am trying to fetch all records after a timestamp with this query

 select from com.chinua.Entity.Comment where date  'Sat Apr 17
 21:40:05 UTC 2010' order by date desc

 The query just returns 0 records but there dates after Sat Apr 17.

 Can anyone help me out?

 Thanks
 CHINUA

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



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



Re: [appengine-java] [JDO Paging] Getting a cursor BEFORE the end of results

2010-05-07 Thread Chau Huynh
Thank you very much, Jeff. I'm so happy to learn those.
I will definitely try the suggested library.
Thanks.

On Sat, May 8, 2010 at 4:15 AM, Jeff Schnitzer j...@infohazard.org wrote:

 This depends on what you mean by lazily load the entity.  There are
 at least three possible interpretations of lazy loading:

 1) Lazily fetching data across the wire
 2) Lazily converting from protocol buffers to Entity objects
 3) Lazily translating Entity objects to Java POJOs

 The first two steps are encapsulated within the Low-Level API, the
 third step is part of JDO/Objectify/etc.

 I know that when you issue a query, the results are batched in chunks
 of a size that you can control.  #1 and #2 are done together; the data
 is pulled across the wire into materialized Entity objects in
 increments of the batch size.

 Objectify does #3 at the last possible moment; if you do not call
 next() and retrieve a POJO entity, the POJO will not be instantiated.
 You can call hasNext() to determine the existence of another page and
 this will not create a POJO - however, the Low-Level API will create
 the Entity.

 In practice, it's hard to imagine that this matters unless your page
 size is something like 2.  If you have 20 elements on a page, the
 worst-case scenario is that fetching 21 will add 5% to the cost of the
 query.  That's not much.

 You can do what you want with Objectify and I suspect you can do what
 you want with JDO, just don't use getResultList().  Get an actual
 QueryResultIterator so the getCursor() call will return the correct
 location.

 Jeff

 On Thu, May 6, 2010 at 8:48 PM, Chau Huynh cmhu...@gmail.com wrote:
  Hi Jeff,
 
  With JPA I will need to excute getResultList() to get a collection
 
 http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html#getResultList()http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html#getResultList%28%29
  Somehow org.datanucleus.store.appengine.query.getCursor(Iterator? iter)
  can not get the cursor in the middle of my iterator, a null value is
  returned in sample code below.
  I guess getCursor() has something to do with the List returned.
 
  EntityManager em =
  Query query = em.createQuery(queryString);
  query.setMaxResults(pageSize + 1);
  em.getTransaction().begin();
  IteratorTestEntity iterator = query.getResultList().iterator();
  ListTestEntity list = new ArrayListTestEntity();
  for (int i = 0; (i  pageSize)  iterator.hasNext(); i++) {
  list.add(iterator.next());
  }
  Cursor cursor = JPACursorHelper.getCursor(iterator);
  // assert iterator.hasNext() == true and cursor == null
  em.getTransaction().rollback();
 
  Just my curious:
  if I'm able to iterate through the result (using
  com.google.appengine.api.datastore.QueryResultIteratorT)
  is it true that each iterator.hasNext() will lazily load entity from the
  data store?
  My concern is it might cost me more time that way than using
  Query.getResultList(). Please advise.
 
  Thank you.
 
  On Fri, May 7, 2010 at 2:24 AM, Jeff Schnitzer j...@infohazard.org
 wrote:
 
  I'm a little confused by this.  Why doesn't the OP's approach work?
 
  1) Create query, fetch with limit of 21 items
  2) Iterate through 20 items
  3) Get cursor to be used for next page (if necessary)
  4) Iterate to 21st item just to check for existence
 
  Why won't this work?  The documentation seems to imply that this is
  how cursors work...
 
  Jeff
 
  On Thu, May 6, 2010 at 1:03 AM, Ikai L (Google) ika...@google.com
 wrote:
   This is a datastore limitation and not related to JDO/JPA, so you
 won't
   be
   able to do this in Objectify either (you can look at the low-level
 API,
   it
   doesn't provide this functionality). I believe I saw an issue in the
   issues
   tracker about creating cursors from arbitrary locations.
  
   --
   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.
  
 
  --
  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.
 
 
  --
  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

Re: [appengine-java] DataNucleus JPA Lifecycle Callbacks

2010-05-06 Thread Chau Huynh
My entity classes were annotated, and work both in local and appspot. Thanks

On Thu, May 6, 2010 at 4:02 PM, Simon qila...@gmail.com wrote:

 Has anyone managed to get the JPA lifecycle callbacks to work?

 I've annotated methods with @PrePersist and @PostLoad and the methods
 just never get called.  I followed the documentation at

 http://www.datanucleus.org/products/accessplatform_2_0/jpa/lifecycle_callbacks.html
 just to make sure that my methods had the correct signatures.

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



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



Re: [appengine-java] Re: DataNucleus JPA Lifecycle Callbacks

2010-05-06 Thread Chau Huynh
Here you are ..

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PostLoad;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;

@Entity
public class LeaveItem implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue (strategy = GenerationType.IDENTITY)
private Long id;

private Date dateStart;

transient private int start;

transient private int end;

transient private int month;

transient private int year;

@SuppressWarnings(unused)
private int monthTag; // de-normalize

@SuppressWarnings(unused)
@PostLoad
private void postLoad() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(dateStart);
start = calendar.get(Calendar.DAY_OF_MONTH);
month = calendar.get(Calendar.MONTH) + 1;
year = calendar.get(Calendar.YEAR);
}

@SuppressWarnings(unused)
@PrePersist
@PreUpdate
private void setMonthTag() {
this.monthTag = DateUtil.toIntTag(dateStart); // to QMM
}


}


On Thu, May 6, 2010 at 4:24 PM, Simon qila...@gmail.com wrote:

 Well I'm confused then.  I've annotated my class with @PostLoad,
 @PrePersist and @PreUpdate.

 The @PrePersist and @PreUpdate methods never get called, whether the
 methods are located in the @Entity annotated class or in a defined
 @EntityListeners annotated class.  I've tried leaving the persistence
 to the DN dirty-checking persistence and also by manually re-
 persisting the entity using the EntityManager's persist method.

 The @PostLoad method is only ever called if the entity is loaded via
 the EntityManager's find method - if you retrieve a list of the
 entities via a JPA defined query then the @PostLoad method just isn't
 called.

 To the couple of people who have this working, have you got some
 example code/configuration you can share?

 On May 6, 10:15 am, Chau Huynh cmhu...@gmail.com wrote:
  My entity classes were annotated, and work both in local and appspot.
 Thanks
 
 
 
  On Thu, May 6, 2010 at 4:02 PM, Simon qila...@gmail.com wrote:
   Has anyone managed to get the JPA lifecycle callbacks to work?
 
   I've annotated methods with @PrePersist and @PostLoad and the methods
   just never get called.  I followed the documentation at
 
  http://www.datanucleus.org/products/accessplatform_2_0/jpa/lifecycle_.
 ..
   just to make sure that my methods had the correct signatures.
 
   --
   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
 google-appengine-java%2bunsubscr...@googlegroups.comgoogle-appengine-java%252bunsubscr...@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.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group athttp://
 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.comgoogle-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.



Re: [appengine-java] Re: Is there any way that key name/id can be used in JPQL/JDQL?

2010-05-06 Thread Chau Huynh
Have you tried with KeyFactory?
http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/KeyFactory.html

In this post Max Ross of Google guided how to query with Key, may it help
you..
http://gae-java-persistence.blogspot.com/2010/01/querying-with-key-parameters.html

On Thu, May 6, 2010 at 9:10 PM, Kenyth ken...@gmail.com wrote:

 I was partly wrong in the previous post, and finding what was wrong
 also leads me to the answer to the question asked in the previous
 post.

 Even using the encoded String key in conjunction with annotated
 gae.pk-name or gae.pk-id, it is still impossible to make a query
 with only the key name/id. Below is error messages when you try to do
 so:

 key name/id is a sub-component of the primary key.  The datastore
 does not support filtering or sorting by primary key components, only
 the entire primary key

 You have to use the complete primary key to do the query, not part of
 it. So in this case you either make your key name/id the primary key
 or just use the Key instance as the primary key.

 It turns out using the encoded String key in conjunction with
 annotated gae.pk-name or gae.pk-id only provide you with shortcuts
 to access the key name/id, no other benefits.

 On May 6, 7:30 pm, Kenyth ken...@gmail.com wrote:
  Is there any way that key name (or pk-name), key id (or pk-id), or
  even parent key (or parent-key) can be used in a query regardless of
  JPQL or JDQL. I know in the Python edition it's possible (correct me
  if I'm wrong).
 
  If there's no way to use this kind query, then the power of key name
  or id (obviously from the GAE doc you can always benefit from a
  annotated parent key) would be very limited *except that you always
  use encoded string key in conjunction with annotated gae.pk-name or
  gae.pk-id*.
 
  // More to read if you would like to...
  From my limited experience with GAE/J, in a normal app key name/id is
  a very simple but powerful way to achieve uniqueness. For example,
  when you have multiple concurrent requests to create a root entity, in
  each request handler you would first check if it exists and then
  decide to create a new one or use the existing one. Without using key
  name/id it's very hard, if possible, to ensure the uniqueness.
 
  Because as far as I know in this case, the global unique key generated
  by the datastore is used to decide the transaction commit will succeed
  or fail. For the root entities, given the same entity kind and the
  same key name/id, the generated key instance will always be the same,
  so you can just let the transaction fail or try it again to rewrite
  it, but using other fields (say, name of a value)  than key name/id,
  in all concurrent transactions a new entity will be created and the
  transaction commit will succeed since the generated key instance will
  always be different from each other.
 
  If in this case I would like to always use key name/id I roughly have
  three choices:
  1. use Long key or unencoded String key for the entity kind, but the
  downside of this is you can't make this entity kind be child of any
  entity kind any more according to the official GAE doc;
  2. use Key instance, but the downside is about this question asked in
  this post: you may use key name/id to make a query;
  3. use encoded String key in conjunction with annotated gae.pk-name
  or gae.pk-id, and the only downside is you have always to use
  KeyFactory to convert the encoded string to a Key instance when you
  need one (e.g., to establish an unowned relationship)
 
  Last, what's described above seems also be true for entities with a
  parent. I'm not sure.
 
  --
  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 athttp://
 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.comgoogle-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.



Re: [appengine-java] [JDO Paging] Getting a cursor BEFORE the end of results

2010-05-06 Thread Chau Huynh
Hi Jeff,

With JPA I will need to excute getResultList() to get a collection
http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html#getResultList()
Somehow org.datanucleus.store.appengine.query.getCursor(Iterator? iter)
can not get the cursor in the middle of my iterator, a null value is
returned in sample code below.
I guess getCursor() has something to do with the List returned.

EntityManager em =
Query query = em.createQuery(queryString);
query.setMaxResults(pageSize + 1);
em.getTransaction().begin();
IteratorTestEntity iterator = query.getResultList().iterator();
ListTestEntity list = new ArrayListTestEntity();
for (int i = 0; (i  pageSize)  iterator.hasNext(); i++) {
list.add(iterator.next());
}
Cursor cursor = JPACursorHelper.getCursor(iterator);
// assert iterator.hasNext() == true and cursor == null
em.getTransaction().rollback();

Just my curious:
if I'm able to iterate through the result (using
com.google.appengine.api.datastore.QueryResultIteratorT)
is it true that each iterator.hasNext() will lazily load entity from the
data store?
My concern is it might cost me more time that way than using
Query.getResultList(). Please advise.

Thank you.

On Fri, May 7, 2010 at 2:24 AM, Jeff Schnitzer j...@infohazard.org wrote:

 I'm a little confused by this.  Why doesn't the OP's approach work?

 1) Create query, fetch with limit of 21 items
 2) Iterate through 20 items
 3) Get cursor to be used for next page (if necessary)
 4) Iterate to 21st item just to check for existence

 Why won't this work?  The documentation seems to imply that this is
 how cursors work...

 Jeff

 On Thu, May 6, 2010 at 1:03 AM, Ikai L (Google) ika...@google.com wrote:
  This is a datastore limitation and not related to JDO/JPA, so you won't
 be
  able to do this in Objectify either (you can look at the low-level API,
 it
  doesn't provide this functionality). I believe I saw an issue in the
 issues
  tracker about creating cursors from arbitrary locations.
 
  --
  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.
 

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



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



Re: [appengine-java] [JDO Paging] Getting a cursor BEFORE the end of results

2010-05-06 Thread Chau Huynh
There's 1 typo in my message, please read

org.datanucleus.store.appengine.query.CursorHelper.getCursor(Iterator?
iter)

Thanks

On Fri, May 7, 2010 at 10:48 AM, Chau Huynh cmhu...@gmail.com wrote:

 Hi Jeff,

 With JPA I will need to excute getResultList() to get a collection

 http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html#getResultList()http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html#getResultList%28%29
 Somehow org.datanucleus.store.appengine.query.getCursor(Iterator? iter)
 can not get the cursor in the middle of my iterator, a null value is
 returned in sample code below.
 I guess getCursor() has something to do with the List returned.

 EntityManager em =
 Query query = em.createQuery(queryString);
 query.setMaxResults(pageSize + 1);
 em.getTransaction().begin();
 IteratorTestEntity iterator = query.getResultList().iterator();
 ListTestEntity list = new ArrayListTestEntity();
 for (int i = 0; (i  pageSize)  iterator.hasNext(); i++) {
 list.add(iterator.next());
 }
 Cursor cursor = JPACursorHelper.getCursor(iterator);
 // assert iterator.hasNext() == true and cursor == null
 em.getTransaction().rollback();

 Just my curious:
 if I'm able to iterate through the result (using
 com.google.appengine.api.datastore.QueryResultIteratorT)
 is it true that each iterator.hasNext() will lazily load entity from the
 data store?
 My concern is it might cost me more time that way than using
 Query.getResultList(). Please advise.

 Thank you.


 On Fri, May 7, 2010 at 2:24 AM, Jeff Schnitzer j...@infohazard.orgwrote:

 I'm a little confused by this.  Why doesn't the OP's approach work?

 1) Create query, fetch with limit of 21 items
 2) Iterate through 20 items
 3) Get cursor to be used for next page (if necessary)
 4) Iterate to 21st item just to check for existence

 Why won't this work?  The documentation seems to imply that this is
 how cursors work...

 Jeff

 On Thu, May 6, 2010 at 1:03 AM, Ikai L (Google) ika...@google.com
 wrote:
  This is a datastore limitation and not related to JDO/JPA, so you won't
 be
  able to do this in Objectify either (you can look at the low-level API,
 it
  doesn't provide this functionality). I believe I saw an issue in the
 issues
  tracker about creating cursors from arbitrary locations.
 
  --
  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.
 

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




-- 
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] Versioning error using primitive int/Integer

2010-05-06 Thread Chau Huynh
Hello app engine team,

It seems to me there is an issue trying to persist a @Version int field.
System reports error ClassCassException from Long to Integer...

java.lang.ClassCastException: java.lang.Long cannot be cast to
java.lang.Integer
at test.TestEntity.jdoReplaceField(TestEntity.java)
at
org.datanucleus.state.JDOStateManagerImpl.replaceField(JDOStateManagerImpl.java:2687)
at
org.datanucleus.state.JDOStateManagerImpl.replaceField(JDOStateManagerImpl.java:2566)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.handleVersioningBeforeWrite(DatastorePersistenceHandler.java:415)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.insertPreProcess(DatastorePersistenceHandler.java:351)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObjects(DatastorePersistenceHandler.java:251)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObject(DatastorePersistenceHandler.java:240)
at
org.datanucleus.state.JDOStateManagerImpl.internalMakePersistent(JDOStateManagerImpl.java:3185)
at
org.datanucleus.state.JDOStateManagerImpl.flush(JDOStateManagerImpl.java:4513)
at
org.datanucleus.ObjectManagerImpl.flushInternal(ObjectManagerImpl.java:2814)
at org.datanucleus.ObjectManagerImpl.flush(ObjectManagerImpl.java:2754)
at
org.datanucleus.ObjectManagerImpl.preCommit(ObjectManagerImpl.java:2893)
at
org.datanucleus.TransactionImpl.internalPreCommit(TransactionImpl.java:369)
at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:256)
at
org.datanucleus.jpa.EntityTransactionImpl.commit(EntityTransactionImpl.java:104)
at
org.datanucleus.store.appengine.jpa.DatastoreEntityTransactionImpl.commit(DatastoreEntityTransactionImpl.java:55)
at test.TestServlet.myInit(TestServlet.java:62)
at test.TestServlet.doGet(TestServlet.java:47)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at
com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:51)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at
com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at
com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:349)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)


package test;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Version;

@Entity
public class TestEntity {
@Id
@GeneratedValue (strategy = GenerationType.IDENTITY)
private Long id;

@Version
private int version;

private String data;

public String getData() {
return data;
}

public void setData(String data) {
this.data = data;
}
}


TestEntity entity = new TestEntity();
entity.setData(test);
EntityManager em = EMF.get().createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
em.persist(entity);
tx.commit();

-- 
You received this message because you are 

[appengine-java] Common Annotations - javax.annotation.PostConstruct

2010-05-05 Thread Chau Huynh
Hello,

Can anyone please advise how to get @PostConstruct invoked in App Engine
(SDK version 1.3.3.1)?
I tried with servlet and JPA/JDO but the conallback method was not
triggered.
Can you please take a look and let me know if I missed something? Thanks.


public class TestServlet extends HttpServlet {
Logger logger = Logger.getLogger(TestServlet.class.getName());

@PostConstruct
private void myPostConstructCallback () {
   logger.warning(PostConstruct callback done);
}
   ...
}

@Entity
public class TestEntity {
@Id
private Long id;

private String value;

@PostConstruct
private void myPostConstructCallback () {
   value = inited;
}
}

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



Re: [appengine-java] Cursor support with JPA

2010-05-05 Thread Chau Huynh
Hi,
Cursor provides a point so that query will execute after that.
I don't think you can achieve the same thing with query.setFirstResult()

Below is code I ran based on consulting JDO example and JPA javadocs. Hope
this helps

EntityManager em = ...
Query query = em.createQuery(queryString);
query.setMaxResults(pageSize);

ListUser users = query.getResultList();

if (users.size() == pageSize) {
Cursor cursor = JPACursorHelper.getCursor(users);
if (cursor != null) {
String cursorString = cursor.toWebSafeString();
// store cursorString for later use
}
}



Query query = em.createQuery(queryString); // same query above
query.setMaxResults(pageSize);
Cursor cursor = Cursor.fromWebSafeString(cursorString);
if (cursor != null) {
query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
}
ListUser users = query.getResultList();
...

On Thu, May 6, 2010 at 5:27 AM, fvisticot fvisti...@gmail.com wrote:

 I do not see any documentation regarding cursor support with JPA.

 Is the following code the correct way to use cursors ?
 In this sample code, i will retrieve users from 300 to 320
 (query.setMaxResults(20);   query.setFirstResult(300);)

 The test is OK with the Local Eclipse GAE plugin

 @Test
public void getUsersCursorTest() {
EntityManagerFactory emf = null;
EntityManager em = null;
emf = AppEntityManagerFactory.get();
try {
em = emf.createEntityManager();
Query query = em.createNamedQuery(User.findAll);
query.setMaxResults(20);
query.setFirstResult(300);
ListUser users = query.getResultList();
_logger.info(UsersWithMax:  + users.size());
for (User user: users) {
_logger.info(User:  + user);
}
} finally {
if (em != null)
em.close();
}
}

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



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



Re: [appengine-java] [JDO Paging] Getting a cursor BEFORE the end of results

2010-05-05 Thread Chau Huynh
About JDO/JPA, I tried the same thing, and Google advised to make 2 calls:
the first one is your query,
the second one, which is a key-only  single item query so that it can be
cheap, to check if more data is available.
http://groups.google.com/group/google-appengine-java/browse_thread/thread/80f1a0314987f26b?pli=1

On Thu, May 6, 2010 at 12:18 AM, James jamesk...@gmail.com wrote:

 I'm implementing some UI paging and trying to detect whether a record
 exists beyond the current page (in order to show a more button).

 I hoped to iterate over a result set of pageSize + 1, grabbing the
 cursor as I pass the item @ pageSize, and then using the existence of
 the last item to know there's more to be shown.  Unfortunately I can't
 find a way to accomplish this using JDO.

 JDOCursorHelper.getCursor(ListT) is documented to get the cursor for
 the last item in the list, so that works as documented but doesn't
 help me.

 JDOCursorHelper.getCursor(IteratorT) seems to be what I need, but
 every Iterator that I can find to pass to it causes it to return
 null.  I've tried passing ((ListT)query.execute).iterator() as well
 as ((QueryResult)query.execute).iterator() and both have the same
 result.

 Anyone know if there's a not-too-kludgy way to do this w/o requerying
 the datastore for the additional item.  Or is it easier in Objectify
 (I'm considering switching)?

 Thanks much,

 James

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



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



Re: [appengine-java] Datastore cursor return value question - CursorHelper.getCursor(List?)

2010-04-30 Thread Chau Huynh
Thank you Ikai

On Fri, Apr 30, 2010 at 4:29 AM, Ikai L (Google) ika...@google.com wrote:

 You'll have to do another query since we don't peek ahead to see if
 you're at the end of the query result or not. You can optimize this,
 however, by doing a keys only query so you don't have to fetch the entities:


 http://code.google.com/appengine/docs/java/datastore/queriesandindexes.html#Queries_on_Keys

 On Wed, Apr 21, 2010 at 4:10 AM, Chau Huynh cmhu...@gmail.com wrote:

 Hello app engine team,

 I'd like to have a search form, which allows user to search next if more
 result available by using a Cursor.
 My issue is, in the last chunk, I am not able to detect if it's.
 Therefore, I will need to execute one additional query to test if more
 data.
 Can you please advise if other approach, without using the 2nd query.
 Thanks.

 By document, CursorHelper.getCursor(List?) will return a Cursor which
 points to the last element in the list.
 The code is below (correct according to doc)

 import com.google.appengine.api.datastore.Cursor;

 EntityManager em = ...
 Query query = em.createQuery(queryString);
 query.setMaxResults(20);
 em.getTransaction().begin();
 ListTestEntity testEntities = query.getResultList();
 Cursor cursor = JPACursorHelper.getCursor(testEntities);
 em.getTransaction().rollback();

 Then I will need to invoke one more call later, to check a null cursor
 returned indicates no more data available
 query.setMaxResults(1);
 query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
 em.getTransaction().begin();
 ListTestEntity testEntities = query.getResultList();
 Cursor cursor = JPACursorHelper.getCursor(testEntities);
 em.getTransaction().rollback();

 By curiosity (please correct me if I'm wrong), I looked into
 org.datanucleus.store.appengine.query
 and found that StreamingQueryResult returned by DatastoreQuery,
 which was in fact constructed from
 com.google.appengine.api.datastore.QueryResultList.
 The document say return a cursor that points to the result immediately
 after the last one in this list.

 http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/QueryResultList.html#getCursor()http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/QueryResultList.html#getCursor%28%29

 So I wonder if CursorHelper.getCursor(List?) can have something similar?

 Thank you.

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


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



Re: [appengine-java] Can you use cursors to go back?

2010-04-30 Thread Chau Huynh
You can find a more detailed discussion on this here
http://groups.google.com/group/google-appengine-java/browse_thread/thread/da8b96441b0ae038/667aac2bb4109097?lnk=raot

On Fri, Apr 30, 2010 at 1:17 AM, korey_sed kouro...@gmail.com wrote:

 I wonder if the java datastore API's cursor is a forward only cursor
 or not?  if not, how do you go back?

 q.setExtend(-20,0) //to get the previous 20?

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



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



Re: [appengine-java] Data store Low-level API and filters

2010-04-30 Thread Chau Huynh
Maybe Query.addFilter() can help you?
http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Query.html#addFilter%28java.lang.String,%20com.google.appengine.api.datastore.Query.FilterOperator,%20java.lang.Object%29

Just wonder if JPA/JDO can fit into your case:
http://gae-java-persistence.blogspot.com/2009/10/executing-batch-gets.html
The example use keys for batch get, but I think you can apply the same
concept.

On Fri, Apr 30, 2010 at 2:23 PM, dominity domin...@gmail.com wrote:

 Hi, guys.

 Can you tell me how could I add filter to query with OR operation?
 I.e., if I want to fetch all entities that have a field with certain
 value or with another one.

 Best regards, Alexander.

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



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



Re: [appengine-java] Re: Querying child objects based on parent key

2010-04-30 Thread Chau Huynh
I think korey_sed wanted to share knowledge base on his hand on experience,
his example should work...
The point in his example is querying with key, whether it's in child on
parent or child class
http://gae-java-persistence.blogspot.com/2010/01/querying-with-key-parameters.html

Obviously loading a patent class should work, but in case you have many
deleted Person, is it a waste (serialization)?

On Fri, Apr 30, 2010 at 8:14 PM, ailinykh ailin...@gmail.com wrote:

 JDO is a thin layer which gives you some kind of automation and
 restriction.
 But it exists only an run time. I mean you have to instantiate objects
 first. In other words
 Company c = getCompany();
 for(Person p:c.getPersons()){
   if(p.isDeleted())
  continue;
  //do what ever you want to do
 }



 On Apr 29, 1:15 pm, korey_sed kouro...@gmail.com wrote:
  I struggled with this for a while and could not find a clear example,
  so I hope it helps someone out there.
 
  I have a company object that has employees and employees could be
  deleted (boolean property).  So I wanted to search for all employees
  for company X where the company is not deleted.  It should be noted
  that I have a bidrectional owned relationship setup between Company
  and Person.
 
  here is how I did it in JDO:
 
  code
  Key companyKey = KeyFactory.stringToKey(companyKeyString);
  String queryStr = select from  + Person.class.getName() +
   where company == companyParam  deleted ==
 false;
  Query q = pm.newQuery(queryStr);
  q.declareVariables(Company.class.getName() +  companyParam);
  persons = (ListPerson)q.execute(companyKey);
  /code
 
  --
  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 athttp://
 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.comgoogle-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.



Re: [appengine-java] Re: Data store Low-level API and filters

2010-04-30 Thread Chau Huynh
Hi, Query.addFilter() help to add filter, but not with OR operation as your
need (sorry for my bad reading).

http://gae-java-persistence.blogspot.com/2009/12/queries-with-and-in-filters.html
This post explained that JPA/JDO (datanucleus-appengine) in fact break the
query into multiple ones.
If you go with low level API, then Tristan's suggestion should help in this
case.
(break the query and merge result instead let the library do it for you)
Thanks.

On Sat, May 1, 2010 at 3:11 AM, dominity domin...@gmail.com wrote:

 Thanx for reply.

 But, how do you propose to implement OR operation with
 Query#addFilter()? As I understand several filters are executed with
 AND operation.
 OR operation with JDO/JPA is trivial and I'm not interested in JDO/JPA
 implementation, thanx.

 Best regards, Alexander.

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



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



[google-appengine] Re: Mixed authenticated and unauthenticated content?

2010-04-30 Thread Chau
Please take a look into 
http://code.google.com/appengine/docs/java/config/webxml.html#Security_and_Authentication
if it helps.
Most often, the answer from the groups for custom authenticate /
authorization (particular set of users in your post) is to build your
own one.
Thanks

On Apr 30, 1:41 am, Craig Berry cdbe...@gmail.com wrote:
 ...Or to put my earlier question a different way, what's the right
 or easy way to accomplish that kind of part-public,
 part-login-protected design in GAE?

 On Thu, Apr 29, 2010 at 09:27, Craig Berry cdbe...@gmail.com wrote:
  I am building a GAE app which acts something like a CMS. Authenticated
  users in a particular set can manipulate content in the datastore, but
  anyone can see a page that is a read-only view of that data. I'd
  really like the latter page to be truly public, not requiring
  authentication to view. Is there a way to control the requirement for
  authentication by URL within a single app?

  I'm using Java, if that matters.

  --
  Craig Berry -http://lapidum.org/home.html
  Magicians lie to the universe, and the
  universe believes them.  -- Lenore Berry

 --
 Craig Berry -http://lapidum.org/home.html
 Magicians lie to the universe, and the
 universe believes them.  -- Lenore Berry

 --
 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-appeng...@googlegroups.com.
 To unsubscribe from this group, send email to 
 google-appengine+unsubscr...@googlegroups.com.
 For more options, visit this group 
 athttp://groups.google.com/group/google-appengine?hl=en.

-- 
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-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



Re: [appengine-java] Re: about count query

2010-04-28 Thread Chau Huynh
Thanks for the info. I can see count and tried it. Thank you.

As a side note, I have a look into
org.datanucleus.store.appengine.query.DatastoreQuery
In case of count, it's a call to
com.google.appengine.api.datastore.PreparedQuery.countEntities()
Key only query still need to go through some wrapping/serialization though.
So it seems to me the former is more efficient (currently not support with
limit/offset though).

On Wed, Apr 28, 2010 at 2:41 PM, Joe Fawzy joewic...@gmail.com wrote:

 it is supported ,use it
 u can find several posts about it in this group
 joe

 On Apr 28, 4:47 am, Chau Huynh cmhu...@gmail.com wrote:
  On Wed, Apr 28, 2010 at 5:24 AM, Joe Fawzy joewic...@gmail.com wrote:
 
  select count (this) from User
  Since when app engine support group operation? ;-)
 
 
 
 
 
  On Wed, Apr 28, 2010 at 5:24 AM, Joe Fawzy joewic...@gmail.com wrote:
   Hi all
   i am using JDO and i want to count the number of entities so which is
   more efficient
   using a count quert, eg:
select count (this) from User
   or  key only query
select id from User
then get the count using resultList.size();
 
   by the way , i know that the recommended way on appengine is to
   precompute but this cannot be done in my case
   thanks
   Joe
 
   --
   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.comgoogle-appengine-java%2B
 unsubscr...@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.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group athttp://
 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.comgoogle-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.



Re: [appengine-java] Re: Manually restart GAE on the cloud

2010-04-28 Thread Chau Huynh
In fact, the post owner already uploaded new version but it did not work for
him.
So he wanted to ask for any deploy suggestion, maybe lucky enough on case
basis.

On Thu, Apr 29, 2010 at 2:54 AM, Duong BaTien duong.bat...@gmail.comwrote:

 We increase the version number, load it up, test it, then change to the
 new version, delete the old one.

 BaTien
 DBGROUPS and BudhNet


 On Wed, 2010-04-28 at 11:15 +0700, Chau Huynh wrote:
  Delete the version and redeploy, maybe?
  Or should Google hep you look into your case, as App Engine user do
  not have such direct control on their system to reboot.
 
  On Wed, Apr 28, 2010 at 10:54 AM, Phuong Nguyen phuongn...@gmail.com
  wrote:
  I think disable/enable your app doesnot reboot JVM.
 
  I'm trying FreeMarker. If JVM process a class for the first
  time, then
  VerifyError is thrown. On second time, it throw
  NoClassDefFoundError.
  When I disabled and reenabled, JVM still throws
  NoClassDefFoundError.
  So I guess JVM is not restarted.
 
  On Apr 28, 10:00 am, Thomas mylee...@gmail.com wrote:
   In the Admin Console you can disable your application and
  re-enable
   it. I think it is much like a JVM reboot.
  
   --
   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.comappengine-java%2bunsubscr...@googlegroups.com
 .
   For more options, visit this group
  athttp://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.comappengine-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.

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



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



Re: [appengine-java] What happens when I don't close persistenceManagers?

2010-04-28 Thread Chau Huynh
Hi Jaroslav,

I think the Article entity returned was detached already, right?
In fact you can try a simple test by modifying the returned object and
verify it value on Admin Console.

The PersistenceManagerFactory takes time to init, but once only (
http://code.google.com/appengine/docs/java/gettingstarted/usingdatastore.html
)
while it's cheap to create as many PersistenceManager's as your need.

Thanks

2010/4/29 Jaroslav Záruba jaroslav.zar...@gmail.com

 What are possible consequences of having method like this?

 --
 public Article getArticle(Key key)
 {
return
 pManagerFactory.getPersistenceManager().getObjectById(Article.class,
 key);
 }
 --

 Is it generally wrong? I.e. will I run out of available pManagers?
 And if it is OK, for how long can I call setters on non-detached
 object to have those changes propagated to data-store?

 Regards
  J. Záruba

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



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



Re: [appengine-java] Specifying a date filter in a query

2010-04-27 Thread Chau Huynh
http://www.datanucleus.org/products/accessplatform_2_0/jdo/jdoql.htmlExample
3 is the right answer for you.
It might be better if you could go through document to have an understanding
on its concepts first.
Thanks.

On Wed, Apr 28, 2010 at 1:36 AM, Vinay vinaytand...@gmail.com wrote:

 Hi,
 I am new to Java and App engine. I am trying to query data that has
 been written to the datastore using JDO. I am getting an exception
 when I try to filter on a Date property:

Query query = pm.newQuery(DataPoint.class);
query.setFilter( m_tradeDateTime  DATETIME(2010, 10,1,
 0, 0,0));

ListDataPoint dp = (ListDataPoint)query.execute();

 m_tradeDateTime  is of type Date. DATE or DATETIME fails when the
 query is parsed. What is the right way of specifying a date value in a
 filter? Filtering on a string property works correctly, not sure what
 is the expected format for specifying a value for a Date type
 property.

 Thanks,
 -Vinay

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



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



Re: [appengine-java] about count query

2010-04-27 Thread Chau Huynh
On Wed, Apr 28, 2010 at 5:24 AM, Joe Fawzy joewic...@gmail.com wrote:
select count (this) from User
Since when app engine support group operation? ;-)

On Wed, Apr 28, 2010 at 5:24 AM, Joe Fawzy joewic...@gmail.com wrote:

 Hi all
 i am using JDO and i want to count the number of entities so which is
 more efficient
 using a count quert, eg:
  select count (this) from User
 or  key only query
  select id from User
  then get the count using resultList.size();

 by the way , i know that the recommended way on appengine is to
 precompute but this cannot be done in my case
 thanks
 Joe


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



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



Re: [appengine-java] Re: Manually restart GAE on the cloud

2010-04-27 Thread Chau Huynh
Delete the version and redeploy, maybe?
Or should Google hep you look into your case, as App Engine user do not have
such direct control on their system to reboot.

On Wed, Apr 28, 2010 at 10:54 AM, Phuong Nguyen phuongn...@gmail.comwrote:

 I think disable/enable your app doesnot reboot JVM.

 I'm trying FreeMarker. If JVM process a class for the first time, then
 VerifyError is thrown. On second time, it throw NoClassDefFoundError.
 When I disabled and reenabled, JVM still throws NoClassDefFoundError.
 So I guess JVM is not restarted.

 On Apr 28, 10:00 am, Thomas mylee...@gmail.com wrote:
  In the Admin Console you can disable your application and re-enable
  it. I think it is much like a JVM reboot.
 
  --
  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 athttp://
 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.comgoogle-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.



Re: [appengine-java] Handling concurrent modification

2010-04-23 Thread Chau Huynh
Maybe you can look into low level API to obtain a lock
http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/memcache/MemcacheService.html#increment%28java.lang.Object,%20long%29

There're also sample implementation using this posted in the group
https://groups.google.com/group/google-appengine/browse_thread/thread/253b9f79f0c178d9/0188ee19a3460ec4?#0188ee19a3460ec4

On Fri, Apr 23, 2010 at 11:23 AM, Phuong Nguyen phuongn...@gmail.comwrote:

 Hi guys:
 I'm creating an app that I need to deal with concurrent modification of
 object.
 Given I have an object that I need to store on memcache.
 Now, given my user base would be big enough for two request to arrive
 simultaneously at  two different servers in the cloud.
 So, in order to modify the object, the server #1 that receive request fetch
 the object from memcache (Correct me if I'm wrong: this will deserialized
 raw data on memcache in to Java Object on Server #1 JVM), modify it and then
 put it back to memcache (which in turn serialize the object).
 At the same time, server #2 tried to modify the object on memcache.

 Under this scenario: Server #1 fetch object Server #2 fetch object 
 Server #1 store object  Server #2 store object
 Then all changes make by Server #1 will be overrided by Server #2.

 If these 2 requests happen on the same Server (and in effect, the same
 JVM), then I believe the use of synchronized access will help. But in case
 they happen on different server, then I don't know how to handle them yet.

 Would you guys advice me on that?
 Thanks.


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



-- 
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] Datastore cursor return value question - CursorHelper.getCursor(List?)

2010-04-21 Thread Chau Huynh
Hello app engine team,

I'd like to have a search form, which allows user to search next if more
result available by using a Cursor.
My issue is, in the last chunk, I am not able to detect if it's.
Therefore, I will need to execute one additional query to test if more data.

Can you please advise if other approach, without using the 2nd query.
Thanks.

By document, CursorHelper.getCursor(List?) will return a Cursor which
points to the last element in the list.
The code is below (correct according to doc)

import com.google.appengine.api.datastore.Cursor;

EntityManager em = ...
Query query = em.createQuery(queryString);
query.setMaxResults(20);
em.getTransaction().begin();
ListTestEntity testEntities = query.getResultList();
Cursor cursor = JPACursorHelper.getCursor(testEntities);
em.getTransaction().rollback();

Then I will need to invoke one more call later, to check a null cursor
returned indicates no more data available
query.setMaxResults(1);
query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
em.getTransaction().begin();
ListTestEntity testEntities = query.getResultList();
Cursor cursor = JPACursorHelper.getCursor(testEntities);
em.getTransaction().rollback();

By curiosity (please correct me if I'm wrong), I looked into
org.datanucleus.store.appengine.query
and found that StreamingQueryResult returned by DatastoreQuery,
which was in fact constructed from
com.google.appengine.api.datastore.QueryResultList.
The document say return a cursor that points to the result immediately after
the last one in this list.
http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/QueryResultList.html#getCursor()

So I wonder if CursorHelper.getCursor(List?) can have something similar?

Thank you.

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



Re: [appengine-java] Re: One - Many Child Persistence help

2010-04-20 Thread Chau Huynh
On Tue, Apr 20, 2010 at 5:48 PM, DeliveryNinja noble1...@googlemail.comwrote:

 It seems that having any data in the ListComment comments in the
 Content.java causes the serialization error. Even when I've removed
 all the data from the Serializable class Comment.java. So it has
 nothing but a constructor.


In this post, Max Ross of Google explained on serialized fields and wrapper
of List. Maybe his advise can help you
http://groups.google.com/group/google-appengine-java/browse_thread/thread/747ceed8396c0ed8/10ccdd1a0c376825

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



Re: [appengine-java] Google App Engine for Java app couldn’t find javac ?

2010-04-20 Thread Chau Huynh
Please try verification step in Getting Java session from the tutorial
http://code.google.com/appengine/docs/java/gettingstarted/installing.html

java -version
javac -version

If error, it's likely you need to add {JAVA_HOME}\bin to Path variable.
Typically you might need to remove bin out of your JAVA_HOME setting C:
\Program Files (x86)\Java\jdk1.6.0_18\bin.
Thanks.

On Wed, Apr 21, 2010 at 3:56 AM, fni min...@gmail.com wrote:

 I'm learning to use Google App Engine, I installed it in Netbeans, the
 project works, but when I clicked on Deploy To Google App Engine, I
 got the following error :

 Beginning server interaction for ...
 0% Creating staging directory
 5% Scanning for jsp files.
 8% Compiling jsp files.
 11% Compiling java files.

 Error Details:
 Apr 20, 2010 3:51:23 PM org.apache.jasper.JspC processFile
 INFO: Built File: \PayPal_Monitor.jsp

 java.lang.IllegalStateException: cannot find javac executable based on
 java.home, tried C:\Program Files (x86)\Java\jre6\bin\javac.exe and
 C:\Program Files (x86)\Java\bin\javac.exe

 Unable to update app: cannot find javac executable based on java.home,
 tried C:\Program Files (x86)\Java\jre6\bin\javac.exe and C:\Program
 Files (x86)\Java\bin\javac.exe

 Please see the logs [C:\Users\NM\AppData\Local\Temp
 \appcfg3946701335172983337.log] for further information.

 The file javac.exe is in : C:\Program Files (x86)\Java
 \jdk1.6.0_18\bin

 How can I add it to java.home ? I'm using Win Vista, and I tried to
 add it from System - Environment Variables, but there is no
 java.home in there. So I added JAVA_HOME to it pointing to : C:
 \Program Files (x86)\Java\jdk1.6.0_18\bin

 But it still gives me the same error. I wonder where this java.home
 is, and how to change it ?

 Frank

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



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



Re: [appengine-java] Re: HTTP ERROR 405 with Guestbook Tutorial

2010-04-17 Thread Chau Huynh
On Sat, Apr 17, 2010 at 8:43 AM, bosun david.bo...@gmail.com wrote:
Is there a order requirement in servlet/ element? Or should only one
servlet defined in this section?  Anyone know how does invocation make on
servlets in section of servlet/ and servlet-mapping/ in web.xml ?   Does
invocation go through chains of servlet?

It's because of incorrect servlet and servlet-mapping declaration in
your old web.xml.
Should use each servlet to define 1 servlet only (no limit on numer of
servlet)
The link in web.xml file reference to those syntax
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
or you can just google web.xml for easier explanation.

On Sat, Apr 17, 2010 at 8:43 AM, bosun david.bo...@gmail.com wrote:

 From my observation, form action=/sign method=post in guestbook.jsp
 is expected to trigger doPost method in SignGuestBookServlet but instead, it
 invoks doGet method in GuestbookServlet as it's the first servlet defined in
 web.xml.  Thus, it causes the error message like HTTP method POST is not
 supported by this URL.

 I have been working on this issue for hours and finally I made it worked
 but I have to delete the servlet guestbook from entries in servlet/ and
 servlet-mapping/ in web.xml.  But in tutorial, it didn't mention the
 deletion.  It also works if I moved up the servlet sign to the first entry.
   I don't understand why it behaves like this.  It looks to me that doGet
 method in GuestbookServet other than doPost method in SignGuestbookServlet
 gets invoked immediately after a user clicks Post Greetings, which posts
 data in the form.  Is there a order requirement in servlet/ element? Or
 should only one servlet defined in this section?  Anyone know how does
 invocation make on servlets in section of servlet/ and servlet-mapping/
 in web.xml ?   Does invocation go through chains of servlet?

 After deletion, web.xml now looks like below:
 ?xml version=1.0 encoding=utf-8?
 web-app xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
 xmlns=http://java.sun.com/xml/ns/javaee;
 xmlns:web=http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd;
 xsi:schemaLocation=http://java.sun.com/xml/ns/javaee
 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd; version=2.5
  servlet
 servlet-namesign/servlet-name
  servlet-classguestbook.SignGuestbookServlet/servlet-class
 /servlet
  servlet-mapping
 servlet-namesign/servlet-name
  url-pattern/sign/url-pattern
 /servlet-mapping
  welcome-file-list
 welcome-fileguestbook.jsp/welcome-file
  /welcome-file-list
 /web-app

 On Fri, Apr 16, 2010 at 12:42 PM, bosun david.bo...@gmail.com wrote:

 Hi Chau,
 I used the code in the tutorial with a slightly change.  Data is posted by
 POST method in the form so SignGuestbookServlet should use doPost to handle
 it.
 Anothe thing I am confused is that I can't see log message in Eclipse
 console if I added custom message like log.info or system.out.printlin
 alough I givie guestbook.level = INFO in logging.properties.

 Code below is SignGuestbookServlet.java:
 import com.google.appengine.api.users.UserService;
 import com.google.appengine.api.users.UserServiceFactory;
 public class SignGuestbookServlet {
 private static final Logger log =
 Logger.getLogger(SignGuestbookServlet.class.getName());

 public void doPost(HttpServletRequest req, HttpServletResponse resp)
 throws IOException {
 UserService userService = UserServiceFactory.getUserService();
 User user = userService.getCurrentUser();

 String content = req.getParameter(content);
 if (content == null) {
 content = (No greeting);
 }
 if (user != null) {
 log.info(Greeting posted by user  + user.getNickname() + :
  + content);
 } else {
 log.info(Greeting posted anonymously:  + content);
 }
 resp.sendRedirect(/guestbook.jsp);
 }
 }
 Code below is guestbook.jsp:

 %@ page contentType=text/html;charset=UTF-8 language=java %
 %@ page import=com.google.appengine.api.users.User %
 %@ page import=com.google.appengine.api.users.UserService %
 %@ page import=com.google.appengine.api.users.UserServiceFactory %
 html
   body
 %
 UserService userService = UserServiceFactory.getUserService();
 User user = userService.getCurrentUser();
 if (user != null) {
 %
 pHi, %= user.getNickname() %! (You can
 a href=%= userService.createLogoutURL(request.getRequestURI()) %sign
 out/a.)/p
 %
 } else {
 %
 pHello!
 a href=%= userService.createLoginURL(request.getRequestURI()) %Sign
 in/a
 to include your name with greetings you post./p
 %
 }
 %
 Comment Board:
 form action=/sign method=post
 divtextarea name=content rows=3 cols=60/textarea/div
 divinput type=submit value=Post Greeting //div
 /form
   /body
 /html

 code below is GuestbookServlet.java:
 package guestbook;
 import java.io.IOException;
 import javax.servlet.http.*;
 import com.google.appengine.api.users.User;
 import com.google.appengine.api.users.UserService;
 import

[appengine-java] Deployment Descriptor Filters: typo in example

2010-04-15 Thread Chau Huynh
Hello,

It looks like a typo in
http://code.google.com/appengine/docs/java/config/webxml.html#Filters
Code: filterConfig.doFilter(request, response);
Also sample LogFilterImpl does not implement all methods defined in javax.
servlet.Filter

Can you please take a look and update. Thanks

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



Re: [appengine-java] Re: Objectify - Twig - SimpleDS articles

2010-03-30 Thread Chau Huynh
First of all, please accept big thanks, Andreas. Those knowledge sharing is
helpful to me as well as other learners.

Follow the thread, I think I was a bit misled on benefit of SQL/JDBC on GAE.

In Andreas blog's, he mentioned on learning curve to deal with the mapping:
Java classess -- JDO/JPA - implementation specific to datastore -
Datastore
That's why he looked for low-level wrapper frameworks. (do read his post
first)

Surprisingly, there're even suggestion to him:
Java classes -- JPA -- Hibernate implementation -- 3rd party
implementation (JDBC/SQL) -- Datastore

Data models formally define data elements and relationships among data
elements for a domain of interest. Yes, 100% agree. So, it is honestly
speaking that data model has nothing to do with technology?  What about is
the big mismatch between model and physical storage? and purpose of
object-relational mapping tool? More mappings and less mismatch?

Reading Google GAE docs, forum, blog, as well as other non-Google site (
stackoverflow.com, highscalability.com ..) the stress is, datastore is not
relational DB. What a coincidence!

On Tue, Mar 30, 2010 at 10:47 PM, Sandeep Sathaye sandeep.sath...@gmail.com
 wrote:

 Hi Guillermo,

 I agree with you completely. Here are my thoughts on the subject.

 Relational theory, SQL and JDBC are functional specifications and RDBMS
 vendors implement these specifications. Actually speaking data model has
 nothing to do with technology. A data model in software engineering is an
 abstract model that describes how data is represented and accessed. Data
 models formally define data elements and relationships among data elements
 for a domain of interest.

 The tools which extrapolate proper strategy for storing and accessing data
 on the underlying datastore based on the data model and expose it via SQL
 and JDBC in both client/server and server mode have a great advandage. This
 is our goal at Cloud2db. This abstraction layer also gives you complete
 flexibility of choosing your underlying datastore. For example, we are about
 to release Cloud2db Amazon SimpleDB and Hadoop Hbase implementations soon.

 Thanks,

 Sandeep.
 On Tue, Mar 30, 2010 at 11:03 AM, Guillermo Schwarz 
 guillermo.schw...@gmail.com wrote:

 Andreas,

 I think there is more misunderstanding again.

 SQL can be run on top of a file system (fseek, read, write) or on top of a
 persistent hashmap (datastore).

 If you create a SQL interface on top of any of those, then it is a
 relational database, not a fake but a real relational database. Why would I
 want a relational database? Consistency, for starters. ACID transactions.
 Set operations.

 Read:
 1. http://www.buzzle.com/articles/advantages-of-relational-databases.html
 2. http://www.sunadal.co.uk/db.php
 3.
 http://www.euclideanspace.com/software/information/relational/index.htm

 Working directly with aseembly code and bits may be what you prefer, but
 if history is correct, computer science is about building abstractions. Good
 abstractions. I agree that you can create the wrong tools for the job, but
 that doesn't stop other people to investigate and innovate to create better
 tools (better abstractions).

 BTW: You dont need to use JDBC directly when working with CloudDB or jiql.
 You can always select Hibernate, JDO or even JPA. The advantage of using an
 extra level of abstraction is that if later the DataStore changes or there
 is a new alternative to the DataStore that is faster (but has a new API) all
 you need to do is to reimplement SQL on top of it and voila: All your
 applications have been ported effortlessly. That's the whole point of using
 abstraction layers.

 Cheers,
 Guillermo.


 On Tue, Mar 30, 2010 at 10:49 AM, Andreas Borglin 
 andreas.borg...@gmail.com wrote:


 Ok, you seem to misunderstand me quite a bit here.

 I never said it can't be used. I just said that I don't want to.
 Other than for portability reasons, why would I want to pretend that
 the datastore is relational by using a framework that emulates this?

 My main requirement, which was formed after using j...@gae, is that I
 want to use a framework that has a natural mapping to the datastore.

 I'm not saying that there is anything wrong with JDO/JPA, cloud2db or
 jiql in general. I'm just saying that, for me, it makes more sense to
 use a framework that exposes the true nature of the datastore (which
 is very different from a relational database), instead of hiding it
 under a portable abstraction layer. Simplicity and performance is more
 important than portability for me. That is of course not true for many
 other projects, so I'm only speaking from my perspective.

 If you can argue that jiql (or any other multi-platform framework like
 cloud2db, etc) can provide a natural mapping to the datastore AND be
 as efficient as the low-level wrappers, I'm all ears. j...@gae didn't
 do it for me at least.

 I never said that GWT had anything to do with SQL. I just don't want
 to use JDBC.

 On Mar 30, 

Re: [appengine-java] Adding, updating and deleting fields in app engine's datastore

2010-03-28 Thread Chau Huynh
You might want to use wrapper class (Long instead of long) to add new field
to load existing data.

To remove a property, you will need to update your Java class first, right?
Later retrieval of an instance, the field is not get loaded, then you
save/persist and the field is gone.

About changing property name, my thought is why do you want to challenge
yourself on such matter? Why don't you just remove and add a new field?
http://code.google.com/appengine/articles/datastore/overview.html In this
series of articles explains what is behind your object, so it's not just
your entity/class only, there're indexes as well.

Reading the Google IO session, JDO/JPA is explained as the standard
interface to access GAE service. Just in case you want to move your app out
of GAE, you can still use the those.
You might want to read other alternatives also; Twig, Objectify recently
announced very cool features released...

Thanks.

On Sat, Mar 27, 2010 at 4:11 AM, jbdhl jbirksd...@gmail.com wrote:

 I got an answer to the below questions in this thread:

 http://groups.google.com/group/google-appengine/browse_thread/thread/dc2dcf2e71bc1055
 but was recommended to ask here also. Here goes...

 I try to figure out how easy it is to ruin/break the data in app
 engine's datastore by accident (using JDO). Assume that a class, say
 MyClass, has a number of persistent members, e.g.
   ...
   int a
   int b
   int c
   ...
 and assume a number of MyClass objects have been stored in app
 engine's persistent storage. Now, what will happen if...

   1) a new persistent member variable, int d, is *added* to MyClass?
 The old objects in datastore did not have this variable, so what will
 their d-value be when they are fetched from datastore?

   2) a persistent member variable, int b, is *removed* from MyClass?
 I guess the b field will be removed from all stored MyClass objects?
 If not, what will happen if b is re-added at some later point in time?
 Will the stored MyClass objects now get their old b-value back?

   3) the type of a persistent member variable is changed, e.g. if a
 is converted to a String? What will the value of a be when the already
 stored objects are fetched from datastore?

 By the way: the app engine docs focuses on JDO as the interface to the
 datastore. Is JDO particularly superior to the alternatives? (JPA,
 Objectify, Twig, SimpleDS, Slim3)

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



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



Re: [appengine-java] Re: how to build same entity group

2010-03-25 Thread Chau Huynh
As a non native English speaker also, let me guess If I got you correctly,
dreamy

You want to manipulate Telephone separately, independent of its-owner-to-be,
so you will have a Telephone class.
Similarly, you will have another class for Person.
Because there're no dependency between creating of Person and Telephone, you
will not need to put those in the same transaction (entity group, you thread
subject was a bit confused) - just check Ikai's explanation above.

Now your need to represent when user buys/exchanges some phones? Can you try
this:
class Person {

ListKey phones;
}
You might need to read relationship link above for more detail.

Thanks

On Thu, Mar 25, 2010 at 7:24 PM, dreamy dreamy2c...@gmail.com wrote:

 for instance, you can just use a Key and reference
 the Person in the Telephone.

 you are right. and i just do it as you say.

 public class Telephone{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName=datanucleus, key=gae.encoded-pk,
 value=true)
private String telephone_id;

@Persistent
private String person_id;  //this field point to  Person
 }

 my question is 
 if person have telephone( telephone1,telephone2,telephone3) and user
 update person's telephone is telephone2,telephone3,telephone4,how
 to implements this?
 

 but in a same  transactions , I need update 2 telephone
 object .--telephone1.person_id=null
 telephone4.person_id=person_id.
 and the 2 telephone object is not in same entity group.


 the question seem to equalhow to update  multi  object (same
 class) in same transaction?


 Thank you for your help

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



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



[google-appengine] Re: questions on datastore (lowercase comparison / one character String )

2010-03-23 Thread Chau
It seems to be issue querying with Key param
Please check another article from Max and see if it help:
http://gae-java-persistence.blogspot.com/2010/01/querying-with-key-parameters.html

On Mar 23, 1:47 pm, vchalmel groupeprojeten...@gmail.com wrote:
 Ok Thanks your advices solved my problem with lowercase Comparison.

 I still faces issues with these one-character Strings problem, do
 you know why, when i try to compare a String Attribute in Datastore to
 a one-character String, it throws this java.lang.Character cannot
 be cast to com.google.appengine.api.datastore.Key exception ?

-- 
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-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Re: questions on datastore (lowercase comparison / one character String )

2010-03-22 Thread Chau
You can save storage by just quote Max Ross's article...
http://gae-java-persistence.blogspot.com/2009/11/case-insensitive-queries.html

On Mar 23, 12:27 am, Gleidson - MG - Brasil
gleidson.gmo...@gmail.com wrote:
 If you're using a relational database it's pretty easy to execute case-
 insensitive queries because it's a native feature of the database.  It
 usually looks something like this:

  select * from Person where UPPER(lastName) = 'ROSS'

 This is a challenge for the App Engine Datastore because we rely on
 executing scans over a limited subset of your data and returning
 results as we encounter them.  Consider the following strings in
 lexicographic order:
 ...
 ROSE
 ...
 ROSS
 ...
 ROSTA
 ...
 Rose
 ...
 Ross
 ...
 Rosta
 ...
 rose
 ...
 ross
 ...
 rosta
 ...

 As you can see there could be an unlimited number of rows in between
 'ROSS' and 'Ross', and also between 'Ross' and 'ross' (okay not
 unlimited, we do have a limit on indexed string length, but definitely
 Large), so if we start scanning at 'ROSS' we might have to skip a huge
 number of results before we hit 'Ross', and that doesn't scale.  This
 is why the datastore doesn't support case-insensitive queries.

 Fortunately it's not hard to implement support for case-insensitive
 queries in your application.  Here's the approach: for each field that
 you want to query in a case-insensitive way, create a duplicate field
 that stores the value of that field in either all upper or lowercase
 letters.  Then, have your model object register a pre-persist callback
 with your persistence framework (JPA or JDO), and then populate the
 duplicate fields inside that callback.  Here's what it looks like.

 JPA:
 import javax.persistence.PrePersist;
 import javax.persistence.PreUpdate;

 @Entity
 public class Person {
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   private Long id;
   private String lastName;
   private String uppercaseLastName;

   public Long getId() {
     return id;
   }

   public String getLastName() {
     return lastName;
   }

   public void setLastName(String lastName) {
     this.lastName = lastName;
   }

   @PrePersist
   @PreUpdate
   public void prePersist() {
     if (lastName != null) {
       uppercaseLastName = lastName.toUpperCase();
     } else {
       uppercaseLastName = null;
     }
   }

 }

 public ListPerson getPeopleByLastName(String lastName) {
   Query q = em.createQuery(select from Person where uppercaseLastName
 = :p);
   q.setParameter(p, lastName.toUpperCase());
   return (ListPerson) q.getResultList();

 }

 JDO:
 import javax.jdo.listener.StoreCallback;

 @PersistenceCapable(identityType = IdentityType.APPLICATION)
 public class Person implements StoreCallback {
   @PrimaryKey
   @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
   private Long id;
   private String lastName;
   private String uppercaseLastName;

   public Long getId() {
     return id;
   }

   public String getLastName() {
     return lastName;
   }

   public void setLastName(String lastName) {
     this.lastName = lastName;
   }

   public void jdoPreStore() {
     if (lastName != null) {
       uppercaseLastName = lastName.toUpperCase();
     } else {
       uppercaseLastName = null;
     }
   }

 }

 public ListPerson getPeopleByLastName(String lastName) {
   Query q = pm.newQuery(Person.class, uppercaseLastName == :p);
   return (ListPerson) q.execute(lastName.toUpperCase());

 }

 On 21 mar, 17:41, vchalmel groupeprojeten...@gmail.com wrote:

  Hi !

  I wonder how to compare a String stored in a datastore entity (field
  login) to an entry (also named login) considering their lowercase
  version :
   - I tried : SELECT count(this) FROM +Gestionnaire.class.getName()+
  WHERE LowerCase(login)== LowerCase('+login+') which throws an
  exception

  I have another problem with this query, I don't want to exclude the
  one-character login like, maybe 1, but this also fires an exception
  (  java.lang.Character cannot be cast to
  com.google.appengine.api.datastore.Key )

-- 
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-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



Re: [appengine-java] Re: Discussion on will-it-play-in-app-engine

2010-03-16 Thread Chau Huynh
Hi,
I looked in archive link (http://archive.apache.org/dist/struts/binaries/)
and I could not find the version 1.2.28 as Google document, might be 1.2.8?
(How embarrassed I did not read your message appropriately).

On Tue, Mar 16, 2010 at 8:26 PM, eldandi matias.burch...@gmail.com wrote:

 thank you Chau for your fast reply, but I already looked in there, and
 the mentioned version (1.2.28) doesn't exist in the struts official
 web page or any known public maven2 repository, that is why I raised
 my question here. Any help would be appreciated. I also thought that
 maybe the version was wrong, and maybe it just needs a correction on
 the version number.

 thanks in advance!

 On Mar 15, 11:54 pm, Chau Huynh cmhu...@gmail.com wrote:
  Hi,
  The struts binaries can be found on Struts download page:
 http://struts.apache.org/download.cgi
  Although it's quite a bit difficult to find on Struts 1 page...On Tue,
 Mar 16, 2010 at 4:28 AM, eldandi matias.burch...@gmail.com wrote:
   Hi, I was wondering if someone could please add a link to the download
   page of the struts 1.2.28 version, as I find it very hard to find and
   I see that most of the other supported frameworks have their own
   links.
 
   Thanks!
 
   --
   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.comgoogle-appengine-java%2B
 unsubscr...@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.comgoogle-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.



Re: [appengine-java] FinalizableReferenceQueue

2010-03-03 Thread Chau Huynh
Quote: You can ignore it. It's a red herring
http://tinyurl.com/y8tlejthttp://www.google.com/url?sa=Dq=http://tinyurl.com/y8tlejtusg=AFQjCNFIMnUbbdgwZwSca1czKxGrbQFz8Q.
(
https://groups.google.com/group/google-appengine-java/browse_thread/thread/9d019bda2070e382
)

On Thu, Mar 4, 2010 at 12:04 AM, dominity domin...@gmail.com wrote:

 Hi, guys.

 Some times I can see I the log something like that:

 #
 I 03-03 09:00AM 17.033


 com.google.appengine.repackaged.com.google.common.base.FinalizableReferenceQueue
 $SystemLoader loadFinalizer: Not allowed to access system class
 loader.

 #
 I 03-03 09:00AM 17.050

 com.google.appengine.repackaged.com.google.common.base.internal.Finalizer
 getInheritableThreadLocalsField: Couldn't access
 Thread.inheritableThreadLocals. Reference finalizer threads will
 inherit thread local values.

 #
 I 03-03 09:00AM 17.053


 com.google.appengine.repackaged.com.google.common.base.FinalizableReferenceQueue
 init: Failed to start reference finalizer thread. Reference cleanup
 will only occur when new references are created.
 java.lang.reflect.InvocationTargetException
at
 com.google.appengine.runtime.Request.process-82241ba22a815a34(Request.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:43)
at

 com.google.appengine.repackaged.com.google.common.base.FinalizableReferenceQueue.init(FinalizableReferenceQueue.java:
 127)
at
 com.google.appengine.repackaged.com.google.common.collect.Interners
 $WeakInterner.clinit(Interners.java:118)
at

 com.google.appengine.repackaged.com.google.common.collect.Interners.newWeakInterner(Interners.java:
 59)
at

 com.google.appengine.repackaged.com.google.io.protocol.ProtocolSupport.clinit(ProtocolSupport.java:
 55)
at com.google.apphosting.api.DatastorePb
 $Query.init(DatastorePb.java:1185)
at com.google.apphosting.api.DatastorePb$Query
 $1.init(DatastorePb.java:2677)
at com.google.apphosting.api.DatastorePb
 $Query.clinit(DatastorePb.java:2677)
at

 com.google.appengine.api.datastore.QueryTranslator.convertToPb(QueryTranslator.java:
 28)
at

 com.google.appengine.api.datastore.PreparedQueryImpl.convertToPb(PreparedQueryImpl.java:
 151)
at

 com.google.appengine.api.datastore.PreparedQueryImpl.runQuery(PreparedQueryImpl.java:
 111)
at

 com.google.appengine.api.datastore.PreparedQueryImpl.asQueryResultIterator(PreparedQueryImpl.java:
 89)
at com.google.appengine.api.datastore.BasePreparedQuery
 $2.iterator(BasePreparedQuery.java:45)
at com.google.appengine.api.datastore.BasePreparedQuery
 $2.iterator(BasePreparedQuery.java:42)
at

 org.datanucleus.store.appengine.query.RuntimeExceptionWrappingIterable.iterator(RuntimeExceptionWrappingIterable.java:
 42)
at
 org.datanucleus.store.appengine.query.LazyResult.init(LazyResult.java:
 67)
at

 org.datanucleus.store.appengine.query.StreamingQueryResult.init(StreamingQueryResult.java:
 63)
at

 org.datanucleus.store.appengine.query.DatastoreQuery.newStreamingQueryResultForEntities(DatastoreQuery.java:
 399)
at

 org.datanucleus.store.appengine.query.DatastoreQuery.wrapEntityQueryResult(DatastoreQuery.java:
 372)
at

 org.datanucleus.store.appengine.query.DatastoreQuery.fulfillEntityQuery(DatastoreQuery.java:
 364)
at

 org.datanucleus.store.appengine.query.DatastoreQuery.executeQuery(DatastoreQuery.java:
 265)
at

 org.datanucleus.store.appengine.query.DatastoreQuery.performExecute(DatastoreQuery.java:
 228)
at

 org.datanucleus.store.appengine.query.JDOQLQuery.performExecute(JDOQLQuery.java:
 85)
at org.datanucleus.store.query.Query.executeQuery(Query.java:1489)
at org.datanucleus.store.query.Query.executeWithArray(Query.java:
 1371)
at org.datanucleus.jdo.JDOQuery.execute(JDOQuery.java:243)
at

 com.dominity.apac.transfer.dao.impl.AbstractBasicDAO.getByField(AbstractBasicDAO.java:
 162)
at

 com.dominity.apac.transfer.dao.impl.GoogleUserDAO.getByField(GoogleUserDAO.java:
 35)
at

 com.dominity.apac.transfer.service.impl.AbstractEntityService.getByField(AbstractEntityService.java:
 185)
at

 com.dominity.apac.transfer.servlet.ServletUtil.obtainAllEventsForUser(ServletUtil.java:
 790)
at

 com.dominity.apac.transfer.servlet.ReportGenerationServlet.doPost(ReportGenerationServlet.java:
 200)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at
 org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
 487)
at org.mortbay.jetty.servlet.ServletHandler
 $CachedChain.doFilter(ServletHandler.java:1093)
at

 

Re: [appengine-java] Do I still need to use session if I use google user account to authenticate?

2010-02-28 Thread Chau Huynh
Perhaps you'd better use your own userssion with one pojo class
I don't think you would sacrifice User service (and its scalability) to deal
with the concern opok posted below.

Hi opok,
I notice that the user service does not need HttpServletRequest to get the
current context, is that reliable?
Your app might running on multiple VM's, so using Google service is more
reliable than your own implementation, I guess.
I think you might want to check docs on Google account (
http://code.google.com/appengine/docs/java/users/) and also on how to use
session provided by App Engine (
http://code.google.com/appengine/docs/java/config/appconfig.html#Enabling_Sessions
)
My thought is, your user logged on to your GAE app already, they would need
to log out of your app first, in order to log on that app with another ID,
using the same browser.
In this thread, Ikai (Google) explained what was shared when you're using
the service (
https://groups.google.com/group/google-appengine-java/browse_thread/thread/816f81da16ca4ce8/844655a8f604d980?lnk=raot
)
and guidance on how to retain form data (
http://groups.google.com/group/google-appengine-java/browse_thread/thread/7b752a5dfabd4bd0/ed596f644d23a656?lnk=raot
)
You just need to google the group...

On Mon, Mar 1, 2010 at 9:20 AM, yjun hu itswa...@gmail.com wrote:

 Perhaps you'd better use your own userssion with one pojo class

 On Mon, Mar 1, 2010 at 9:49 AM, opok vir...@gmail.com wrote:

 I currently use Google Account to authenticate and get the current
 user like this:

 UserService userAction = UserServiceFactory.getUserService();
 User user = userAction.getCurrentUser();

 I notice that the user service does not need HttpServletRequest to get
 the current context, is that reliable?

 What about my customer use another google id to login in another page
 of my app? Would the current user change when the customer returned to
 the first page to make some other requests ?

 In the past, I always use Session to storage user information to id
 current user, it looks like Google's user service can provide the same
 functionality, so I can abandon the session for that kind of usage, is
 that correct?

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




 --
 dream or truth

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


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



Re: [appengine-java] I'm have a question about Java runtime

2010-02-22 Thread Chau Huynh
I think you can start reading the guide, let me google that for you...
http://code.google.com/appengine/docs/java/datastore/

2010/2/22 Ngô Chí Lê lengo...@gmail.com

 Hi, I'm a new IT, I'm working on Google App Engine using Eclipse, I
 have two questions for you:
 1/I want to create two entities and use one-to-one relationships, how
 can I do that, please help me?
 2/I want to insert a new entity from child, how can I do that, please
 help me?

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



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



Re: [appengine-java] Re: JPA with database

2010-02-21 Thread Chau Huynh
Beside useful hint from Jake, providing links by google search might be
helpful to you http://tinyurl.com/cofmen
Specifically, you might need to look into Get Started guide...

On Fri, Feb 12, 2010 at 4:12 PM, maheswari maheswari rma...@gmail.comwrote:

 is their is any authentication required to run JPA Program that uses the
 Database as Google App Engine


 On Fri, Feb 12, 2010 at 11:40 AM, maheswari maheswari rma...@gmail.comwrote:

 hai

 Thanks for your reply
 But I didnot know where to create a new JPA Project to make databese
 connection with google app engine,
 which option i need go, JPA project,web application project or dynamic web
 project.

 Thanks in advance

 On Fri, Feb 12, 2010 at 4:13 AM, Jake jbrooko...@cast.org wrote:

 It's true that you should read the documentation.  As a former newbie
 and teacher, though, I appreciate the need for some helpful hints:

 JPA is Java's Persistence (Saving) API found in the
 javax.persistence.* package.  You can use JDO as an alternative,
 though, instead of JPA.  I would recommend this simply because Google
 App Engine has better documentation for JDO.  In the end, to the new
 user, they are essentially the same.

 JPA or JDO is how you will save full Java objects into the Google
 database.  It is not difficult to make the database connection if you
 follow the tutorials.  At this stage, it sounds like you will have
 more trouble creating a basic web application.  So, I would start with
 that first - also in the tutorials.  The App Engine SDK comes with a
 few sample projects that should work out of the box - see if you can
 get those up and running.

 Good luck!

 Jake

 On Feb 11, 1:38 pm, datanucleus andy_jeffer...@yahoo.com wrote:
  Really sounds like you ought to read the docs before using the
  softwarehttp://code.google.com/appengine/docs/
  Omitting such a basic step is not advisable.

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



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


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



Re: [appengine-java] how to share local_db.bin to others

2010-02-05 Thread Chau Huynh
http://code.google.com/appengine/docs/java/howto/unittesting.html#Writing_Datastore_Tests
I wonder if your team members can share same test case
and local_db.bin in each of your environment can have similar record.
I just read it, so please try and advise if it work. Thanks
-Chau

On Wed, Feb 3, 2010 at 8:23 PM, dreamy dreamy2c...@gmail.com wrote:

 we have 4 membership in  google app engine project. we code in local
 Machine and manager source by subverion, in devolop ,when some one
 create a record(eg.create a company object) but others membership
 can't use this company object.

  is there any way  to share local_db.bin  to each other  or all
 membership use same local_db.bin ?

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



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



Re: [appengine-java] Question: best practice to persist medium-large data?

2010-01-26 Thread Chau Huynh
Thanks John and Jeff for sharing the knowledge.
I've just quickly scanned your project home, and I have a novice question
that needs your help:
Is twig or Objectify direct replacement to JDO / JPA on GAE? I just need to
use your framework alone, or should use in combination with JDO / JPA
support?

What is about the approach implementing general JDO / JPA fit to
Datastore? Is there a chance Google provide a specific implementation to
their Datastore?
Maybe someone from Google can advise on this?

Thanks,
-Chau

On Tue, Jan 26, 2010 at 2:52 PM, John Patterson jdpatter...@gmail.comwrote:


 On 26 Jan 2010, at 13:37, Jeff Schnitzer wrote:


 I can't resist a conversation about framework design philosophy :-)


 Oh go on then.  Just a quickie.


 This sort of binding (property of ListPhoto) can be convenient in
 some applications, and as a longtime Hibernate user I got used to
 working like this.  But I don't like this abstraction in AppEngine.
 Yes, for some apps you might be able to remove the pollution of
 framework classes like Key (or OKey), but it comes with a price.


 Twig and Objectify operate at very different levels of abstraction.  With
 Objectify you code at a lower level very aware of what is happening at the
 datastore level.  It involves more work but, as you point out, if something
 goes wrong - it goes wrong in your own code where you are in a better
 position to handle it.

 With Twig you operate at a higher level that makes the persistence layer
 almost completely transparent.  One major advantage of this is that you can
 change the way the data is stored (i.e. embedded or separate entity) without
 changing your code.  Making such a change with Objectify means you need to
 rewrite your reference handling code yourself.


 A one-to-many relationship between Album and Photo has several
 standard representations in AppEngine:

 * The Photo could have a Key property pointing to Album

 * The Photo could have a parent ancestor in its Key which points to the
 Album

 * The Album entity could have a ListKey property pointing to its Photos

 Each choice has a dramatic impact on performance, what can be done in
 a transaction, and how you do queries that simply cannot be glossed
 over or abstracted away.


 This is why you configure what type of relationship is used using: @Embed,
 @Entity(PARENT), @Entity(CHILD) or @Entity(INDEPENDENT)

 So you have the flexibility to choose configuration _without_ rewriting
 your code.  Very important difference.

 Currently the first type of representation is not an option.  I do want to
 add this as it makes very large collections that change often much more
 efficient.  When it is added you could reconfigure your data schema by
 changing a single annotation.  Such a change in Objectify would require the
 developer to rewrite their entire data layer

 Which does the ListPhoto represent?
 Furthermore, is ListPhoto a proxy or did the photos get fetched
 along with the Album?  Can I serialize the Album or do I need to
 detach it?


 Yes instances are just normal POJOs so no problems serializing.  I do this
 myself with GWT.

 Currently, lazy references are not supported... its a very important
 feature on the TODO list.


 Even worse, there are also two more possible representations:

 * The Photo could have a Key property (or ancestor) pointing to an
 Album that does not exist


 An inconsistent datastore is a problem with any framework - including
 Objectify.  The trick is to use transactions where possible whenever working
 on an entity group to avoid getting this situation in the first place.

 * The Album could have a ListKey property, and some of the Keys
 could point to Photos that do not exist


 As above.  An exception would be thrown saying which property on what
 object could not be found.

 Maybe these are degenerate cases, maybe not, but you'll never be able
 to completely avoid them.  RDBMSes have transactions and referential
 integrity constraints that guarantee these later two cases can't
 happen.  Not so in AppEngine.  You're just one
 DatastoreTimeoutException away from having to deal with this situation
 in your code.


 If your data is inconsistent you have a problem - whether the framework
 throws an exception (as in Twig) or if you receive a null back from a finder
 method (as in Objectify) there is really not much difference.  You still
 have to clean up the mess.

 This is the big mess that makes JDO on Appengine so complicated,
 possibly even more complicated than it is on an RDBMS.  On the other
 hand... if you simply expose the Key (or OKey), the developer does a
 little more work but doesn't have to figure out all the configuration.
 Without proxies, all entities are serializable and GWT-able without
 any special consideration.


 I think that for simple cases and small data models working with Keys and
 handling the references yourself is fine.  When things get more complicated
 it is easier to reconfigure how the data is actually

Re: [appengine-java] Deploy from separated resources

2010-01-19 Thread Chau Huynh
I'm just curious how you share code among your team without using
subversion?
-Chau

On Tue, Jan 19, 2010 at 10:38 PM, dominity domin...@gmail.com wrote:

 Hi, guys.

 I've got one simple question.
 There is team of developers that creates any kind of web application.
 Web application is hosted on GAE. Team's members are from different
 locations. Any member of team can deploy new version of app. How
 should they behave in this situation to avoid version collisions? How
 should new version be deployed? Are there any suggestions, tips, best
 practices or something like that?

 Also, is there any possibility to upload to GAE only static file of
 the project, but not whole project?

 Best regards, Alexander.

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




-- 

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.



Re: [appengine-java] Re: String as Primary key in JDO

2010-01-16 Thread Chau Huynh
Queries must go with indexes (
http://code.google.com/appengine/docs/java/datastore/queriesandindexes.html)
For the column, you can store it as lowercase/uppercase,
For the display column, you can store the original value.

On Sun, Jan 17, 2010 at 2:15 PM, Sahil Mahajan sahilm2...@gmail.com wrote:

 Isn't there any other way.
 I want to avoid toLowerCase().
 I want String to be case insensitive for database, but while
 displaying String to user I would like it to conserve case..
 I can compare strings through equalsIgnoreCase. But then I won't be
 able to make effective use of primary key.




 On Jan 17, 11:34 am, jd jdpatter...@gmail.com wrote:
  Just String#toLowerCase() the key when you store them
 
  On Jan 17, 1:11 am, sahil mahajan sahilm2...@gmail.com wrote:
 
   I am using String as primary key in JDO. But it is case sensitive. It
   considers name and NAME as different. Can I make it case sensitive?
 
   --
   Regards
   Sahil Mahajan

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




-- 

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.



Re: [appengine-java] jdoql contains method

2009-12-29 Thread Chau Huynh
http://code.google.com/appengine/docs/java/datastore/queriesandindexes.html#Introducing_Queries
In Query Filters section, it mentions that A filter specifies a field
name, an operator, and a value. The value must be provided by the app; it
cannot refer to another field, or be calculated in terms of other fields.
so it seems to me desc.contains(ing) filter might cause the issue.

On Sun, Dec 27, 2009 at 4:19 AM, zackmac zack.macom...@gmail.com wrote:

 I'm trying to use the contains method in a query and having some
 trouble.  The query is formatted like this:

 select from Transactions where userName == 'auser'  account ==
 'anAccount'  desc.contains(ing) order by transDate desc,
 categoryName

 desc is a column in my Transactions table.  Don't think I'm quite
 understanding how the contains method works and how to implement in a
 query.

 I get this error returned on my jsp when I try to run that query:
 org.datanucleus.store.appengine.query.DatastoreQuery
 $UnsupportedDatastoreFeatureException: Problem with query

 --

 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.




--

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.