[appengine-java] Help:I can't make a object persistent completely.

2009-11-23 Thread Jolam
This is the object:
___

@PersistenceCapable(identityType = IdentityType.APPLICATION,
detachable = true)
public class Client implements java.io.Serializable {



@Persistent
private ArrayListOneService serviceRecords;

@Persistent
private ArrayListOneService serviceNow;

@Persistent
private String remarks;

..

public ArrayListOneService getServiceRecords() {
return serviceRecords;
}

public void setServiceRecords(ArrayListOneService serviceRecords) {
this.serviceRecords.clear();
for (int i = 0; i  serviceRecords.size(); i++) {
this.serviceRecords.add(serviceRecords.get(i));
}
}

public ArrayListOneService getServiceNow() {
return serviceNow;
}

public void setServiceNow(ArrayListOneService serviceNow) {
this.serviceNow.clear();
for (int i = 0; i  serviceRecords.size(); i++) {
this.serviceNow.add(serviceNow.get(i));

when i try to make this kind of Object pesistent like this:
___

ArrayListOneService serviceNow = new ArrayListOneService();
serviceNow.add(oneservice);
client.setServiceNow(serviceNow);
___

the ArrayList serviceNow in the Object doesn't contains another
object oneservice i want to add into the ArrayListserviceNow.

p.s. my english is bad and if it makes u confused because of my poor
expression,i beg your pardon.

--

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




[appengine-java] Re: Is there a recommended way to differentiate between production and dev GAE environments?

2009-11-23 Thread leszek
Follow that thread:

http://groups.google.co.uk/group/google-appengine-java/browse_frm/thread/8145f547cbaff99e/453847dda0217e71?q=#453847dda0217e71

--

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




[appengine-java] Re: Local server works, Appspot fails with java.lang.StackOverflowError when Spring AOP is enabled

2009-11-23 Thread laphroaig15
I'm also experiencing Gabriel's topmost stacktrace while attempting to
POC Drools.  Like Kris, I cannot see far enough into the stacktrace to
determine what drools API call is triggering the behavior.  My app is
heroict...@appspot.com.

On Nov 4, 3:43 am, Kris krisajenk...@gmail.com wrote:
 Hi Toby,

 I've just realised that I probably over-wrote the app with a new
 version yesterday.  Did you get what you need? (If not, I can easily
 re-deploy and resend the ID.)

 Cheers,
 Kris

 On Oct 19, 8:30 pm, Toby Reyelts to...@google.com wrote:

  Kris,

  Can you send us your app id (privately if you wish) ?

  On Mon, Oct 19, 2009 at 3:57 PM, Kris krisajenk...@gmail.com wrote:

   I'm also getting this StackOverflowError, but the app engine log view
   is truncated, so I can't see the initial cause.  Is there any way to
   see the whole log message, so I can try to help track it down/produce
   a test case?

   Cheers,
   Kris

   On Oct 7, 4:36 pm, Toby Reyelts to...@google.com wrote:
Unfortunately this is an issue that will be very difficult for us to
   solve
unless you can provide us with a simple reproducing app that we can use
   to
debug. If the issue is important to you, that is the most important 
thing
you can do to help us.On Wed, Oct 7, 2009 at 6:57 AM, Dave Cheong 
   d...@davecheong.com wrote:

 Hi there,

 I'm having the same problem and was wondering if you or anyone else
 out there have found a solution.
 I'm currently using GAE/J 1.2.5 and Spring 2.5.

 Like the previous author, everything works locally but I get a
 StackOverflowError on Appspot. However, if I comment out ...

 aop:aspectj-autoproxy/

 ... things work on Appspot.

 Any help provided is much appreciated.

 thanks,
 dave

 On Aug 26, 3:38 pm, Gabriel Moreira gabrielmore...@gmail.com wrote:
  My app is using Spring 3.0.

  If i disable Spring AOP, my app runs fine both on local and appspot.

  But when i enable Spring AOP (tested with advice or aspects), in
   local
  runtime everything is fine and works, but in appspot im getting this
  error:

  java.lang.StackOverflowError
          at java.lang.String.endsWith(Unknown Source)
          at sun.security.provider.PolicyFile.canonPath(Unknown 
  Source)
          at java.io.FilePermission$1.run(Unknown Source)
          at java.io.FilePermission$1.run(Unknown Source)
          at java.security.AccessController.doPrivileged(Native 
  Method)
          at java.io.FilePermission.init(Unknown Source)
          at java.io.FilePermission.init(Unknown Source)
          at
 sun.net.www.protocol.file.FileURLConnection.getPermission(Unknown
  Source)
          at sun.misc.URLClassPath.check(Unknown Source)
          at sun.misc.URLClassPath$FileLoader.getResource(Unknown
   Source)
          at sun.misc.URLClassPath$FileLoader.findResource(Unknown
   Source)
          at sun.misc.URLClassPath.findResource(Unknown Source)
          at java.net.URLClassLoader$2.run(Unknown Source)
          at java.security.AccessController.doPrivileged(Native 
  Method)
          at java.net.URLClassLoader.findResource(Unknown Source)
          at
 com.google.apphosting.runtime.security.UserClassLoader.findResource
  (UserClassLoader.java:631)
          at java.lang.ClassLoader.getResource(Unknown Source)
          at
   com.google.apphosting.runtime.security.UserClassLoader$4.run
  (UserClassLoader.java:665)
          at
   com.google.apphosting.runtime.security.UserClassLoader$4.run
  (UserClassLoader.java:659)
          at java.security.AccessController.doPrivileged(Native 
  Method)
          at
 com.google.apphosting.runtime.security.UserClassLoader.findResource
  (UserClassLoader.java:659)
          at java.lang.ClassLoader.getResource(Unknown Source)
          at
   com.google.apphosting.runtime.security.UserClassLoader$4.run
  (UserClassLoader.java:665)
          at
   com.google.apphosting.runtime.security.UserClassLoader$4.run
  (UserClassLoader.java:659)
          at java.security.AccessController.doPrivileged(Native 
  Method)
          at
 com.google.apphosting.runtime.security.UserClassLoader.findResource
  (UserClassLoader.java:659)
          at java.lang.ClassLoader.getResource(Unknown Source)
          at
   com.google.apphosting.runtime.security.UserClassLoader$4.run
  (UserClassLoader.java:665)
          at
   com.google.apphosting.runtime.security.UserClassLoader$4.run
  (UserClassLoader.java:659)
          at java.security.AccessController.doPrivileged(Native 
  Method)
          at
  com.google.apphosting.runtime.security.UserClassLoader.findResour...

  My applicationContext.xml:

  ?xml version=1.0 encoding=UTF-8?
  beans xmlns=http://www.springframework.org/schema/beans;
 

[appengine-java] Re: problem with using session.getAttribute()

2009-11-23 Thread Sanjay
Did you solve this problem? I am facing exactly same problem, it would
be nice if you could share the solution if you found one.

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




Re: [appengine-java] A web service with security (java)

2009-11-23 Thread Yiming Li
Hi Andrey,
I don't know the exact answer, but I am just curious
whether this is feasible or easy to do, using a third party library,
because we have to make sure that all the classes that the third party
lib uses are on the white list of Google, also we how is the
authentication user information stored?
Maybe we need to develop an app just for authentication?
then if a user is authorized, they will be redirected to some other
urls.

Yiming

On Thu, Nov 19, 2009 at 5:53 AM, Andrey andrey.si...@gmail.com wrote:
 Hello,

 What java lib or project would you recommend for development a web
 service with security (to give the users the data only according there
 role or userName).

 Thanks,

 -Andrey

 --

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




--

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




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

2009-11-23 Thread Lucas Cavalcanti
Hi,

VRaptor3 (http://vraptor.caelum.com.br/en) also works on GAE, with few
customizations that can be properly downloaded on google code:
http://code.google.com/p/vraptor3/downloads/list (Blank project for
google app engine).

Add VRaptor 3 to this page, please.

Thanks,
Lucas

--

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




[appengine-java] Restricted Class

2009-11-23 Thread fractz
Hi,
What's the deal with all these restricted classes?

http://groups.google.com/group/google-appengine-java/search?group=google-appengine-javaq=restricted+classqt_g=Search+this+group

And can someone explain why we can't simply use a straightforward,
simple, one-of-many-such Java Servlet implementations?

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




[appengine-java] Re: Local server works, Appspot fails with java.lang.StackOverflowError when Spring AOP is enabled

2009-11-23 Thread laphroaig15
Was there any progress on this bug?

--

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




[appengine-java] Re: Moderation enabled

2009-11-23 Thread Marco Ensing
Jason,

Are you still able to process it within 24 hours. I send a post 2 days
ago.

Marco

On Sep 29, 7:55 am, Jason (Google) apija...@google.com wrote:
 Due to the recent uptick in spam messages, I have enabled moderation
 for new members -- this means that if you haven't posted here before,
 your message may not show up right away until I have the opportunity
 to approve it.

 Please do not double-post -- if you don't see your message right away,
 please wait up to 24 hours for it to be posted. Once your first post
 is up, all other posts should appear immediately.

 Thanks,
 - Jason

--

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




[appengine-java] Re: JSF 2.0.1 java.lang.ClassNotFoundException: void

2009-11-23 Thread addy.bhardwaj
I had a similar issue. The way I fixed it was to configure state
saving to client rather than server. For details check my blog
http://consultingblogs.emc.com/jaddy/archive/2009/11/20/jsf2-in-google-app-engine.aspx

Let me know if this fixes your problem.

On Nov 12, 6:15 pm, Mirco Attocchi ami...@gmail.com wrote:
 Problem using majorra 2.0.1 and GAE 1.2.6, but some times pages render
 correctly.

 javax.servlet.ServletException: java.lang.RuntimeException:
 java.lang.ClassNotFoundException: void
         at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle
 (AppVersionHandlerMap.java:240)
         at org.mortbay.jetty.handler.HandlerWrapper.handle
 (HandlerWrapper.java:139)
         at org.mortbay.jetty.Server.handle(Server.java:313)
         at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
 506)
         at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete
 (HttpConnection.java:830)
         at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable
 (RpcRequestParser.java:76)
         at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
         at
 com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceReques t
 (JettyServletEngineAdapter.java:139)
         at com.google.apphosting.runtime.JavaRuntime.handleRequest
 (JavaRuntime.java:239)
         at com.google.apphosting.base.RuntimePb$EvaluationRuntime
 $6.handleBlockingRequest(RuntimePb.java:5135)
         at com.google.apphosting.base.RuntimePb$EvaluationRuntime
 $6.handleBlockingRequest(RuntimePb.java:5133)
         at com.google.net.rpc.impl.BlockingApplicationHandler.handleRequest
 (BlockingApplicationHandler.java:24)
         at com.google.net.rpc.impl.RpcUtil.runRpcInApplication(RpcUtil.java:
 363)
         at com.google.net.rpc.impl.Server$2.run(Server.java:814)
         at com.google.tracing.LocalTraceSpanRunnable.run
 (LocalTraceSpanRunnable.java:56)
         at com.google.tracing.LocalTraceSpanBuilder.internalContinueSpan
 (LocalTraceSpanBuilder.java:516)
         at com.google.net.rpc.impl.Server.startRpc(Server.java:769)
         at com.google.net.rpc.impl.Server.processRequest(Server.java:351)
         at com.google.net.rpc.impl.ServerConnection.messageReceived
 (ServerConnection.java:437)
         at com.google.net.rpc.impl.RpcConnection.parseMessages
 (RpcConnection.java:319)
         at com.google.net.rpc.impl.RpcConnection.dataReceived
 (RpcConnection.java:290)
         at com.google.net.async.Connection.handleReadEvent(Connection.java:
 436)
         at com.google.net.async.EventDispatcher.processNetworkEvents
 (EventDispatcher.java:762)
         at com.google.net.async.EventDispatcher.internalLoop
 (EventDispatcher.java:207)
         at com.google.net.async.EventDispatcher.loop(EventDispatcher.java:
 101)
         at com.google.net.rpc.RpcService.runUntilServerShutdown
 (RpcService.java:251)
         at com.google.apphosting.runtime.JavaRuntime$RpcRunnable.run
 (JavaRuntime.java:396)
         at java.lang.Thread.run(Unknown Source)
 Caused by: java.lang.RuntimeException:
 java.lang.ClassNotFoundException: void
         at com.google.apphosting.runtime.jetty.SessionManager.deserialize
 (SessionManager.java:389)
         at com.google.apphosting.runtime.jetty.SessionManager.loadSession
 (SessionManager.java:307)
         at com.google.apphosting.runtime.jetty.SessionManager.getSession
 (SessionManager.java:282)
         at org.mortbay.jetty.servlet.AbstractSessionManager.getHttpSession
 (AbstractSessionManager.java:237)
         at org.mortbay.jetty.Request.getSession(Request.java:998)
         at
 com.sun.faces.application.WebappLifecycleListener.syncSessionScopedBeans
 (WebappLifecycleListener.java:393)
         at com.sun.faces.application.WebappLifecycleListener.requestDestroyed
 (WebappLifecycleListener.java:117)
         at com.sun.faces.config.ConfigureListener.requestDestroyed
 (ConfigureListener.java:341)
         at org.mortbay.jetty.handler.ContextHandler.handle
 (ContextHandler.java:725)
         at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
 405)
         at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle
 (AppVersionHandlerMap.java:238)
         ... 27 more
 Caused by: java.lang.ClassNotFoundException: void
         at com.google.appengine.runtime.Request.process-7a0672406190a0e0
 (Request.java)
         ... 35 more

--

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




[appengine-java] Help With Images In Java

2009-11-23 Thread java-dev
hi all,

I need some help with images in appengine using java. Now I have
sucessfully uploaded an image file and stored it to the datastore. I
am also able to read back the stored image (as a byte[] array). Now
the issue is, how do I display this image in my jsp page?

***

//gets the image file Object  from the read data d
ImageFile f = d.getImg();

//gets the byte array of this image
byte[] imb = f.getImg();

//futile attempt to display this image
for(int i=0; iimb.length; i++)
out.println(imb[i]);

***
The above code displays the raw bytes on the jsp pageHow can I get
this to display the image itself?

Any help would be greatly appreciated..

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




[appengine-java] Re: Server Code for Chat Service / Matchmaking

2009-11-23 Thread laphroaig15
I'm also interested to hear on this from more experienced GAE
developers.  My understanding so far is that you can only reliably
maintain state by persisting data to the data store on every request.
You can put objects into the memory cache, but since that's volatie,
i.e. can be blown away at any time, it's not reliable.  Even using the
servlet container for a single instance won't work because you have no
control or notification over the number or lifespan of instances (e.g.
it could be spun up to service your request and then be removed two
seconds later).  Intuitively, I don't see how maintaining state via
per request retrieval and persistence could ever scale in a nontrivial
app, but maybe that's a preconceived notion?  I'd love to see some
stats if someone has achieved this?

On Nov 21, 10:35 pm, Craig craig.a.morri...@gmail.com wrote:
 Hi,

 I have some questions regarding the limits of server code in GAE.  Can
 I write server code that isn't tied to an http request - i.e. a thread
 that would always be running on the server and which servlets could
 communicate with?  From what I've read it isn't possible but I just
 wanted to confirm.

 The application I'm writing is analogous to a chat system where 10
 users would log in and indicate their status (busy, idle, etc).  I
 would prefer to be able to write a single server thread which would
 maintain this information and could give it to the individual servlets
 as needed.  I.e. if I could write a persistent thread to manage this
 data I wouldn't need to deal with the data store, memcache, etc.  I
 understand that this isn't possible - but please let me know if it is
 and what term I need to search for.

 Next, please let me know if the following architecture for my app
 makes sense.  Since I cannot write a central thread to manage the
 information and respond to requests, I'll accomplish that using the
 memcache  data store.  As users update their status the servlets will
 update the data.  Then when the other clients refresh themselves, the
 servlets that they spawn will retrieve everyone's status from the data
 store and return it to the client.  Does this structure make sense or
 am I missing something?

 (Eventually I'll use ServerPush to accomplish the refresh but I don't
 think that is relevant to the question).

 Thanks for your response and advice,

 Craig

--

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




Re: [appengine-java] JDO x JPA

2009-11-23 Thread Ikai L (Google)
Both JDO and JPA support are built on top of the low-level API:

http://code.google.com/appengine/docs/java/datastore/overview.html

Anecdotally, I see more articles about JDO on App Engine, but my experience
has been that there are more *general* JPA articles lying around, though
they may not be applicable since they are more geared towards relational
databases. There are also a number of developers simply building
applications using the Low Level API.

On Sat, Nov 21, 2009 at 9:56 AM, Rafael Reuber psico.in...@gmail.comwrote:

 Hi there,

 What's the better suport for GAE, JDO or JPA? I see many examples in
 JDO so I think that it have the better support.

 --
 Rafael Reuber
 MSN/Gtalk: psico.in...@gmail.com

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




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




Re: [appengine-java] Ancestor queries in JPQL? / Getting Key of parameter value does not have a parent

2009-11-23 Thread Ikai L (Google)
I'm happy to add this to the official docs if it isn't clear. I think this
makes sense under the JPA section or the section about ancestor queries.

On Sun, Nov 22, 2009 at 11:24 PM, Rusty Wright rwright.li...@gmail.comwrote:

 There are way too many hidden secrets, like this parent-pk query, that are
 buried throughout the App Engine documentation.  It would really be nice if
 these things were more clearly documented.


 Ikai L (Google) wrote:
  Hey Todd,
 
  There are a few different things you can do here:
 
  1. Use the parent-pk filter. It looks something like this:
 
  query = pm.newQuery(select from Account  +
 
  where parent-pk == keyParam  +
  parameters Key keyParam);
 
 
  There's a groups thread about this here:
 
 http://groups.google.com/group/google-appengine-java/browse_thread/thread/97ba3209ec6a65de
 
  and the docs are here:
 
 
 http://code.google.com/appengine/docs/java/datastore/transactions.html#Using_Transactions(search
 
  2. Use the low-level API.
 
  com.google.appengine.api.datastore.Query has a constructor that takes an
  Ancestor key.
 
 http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Query.html#Query(com.google.appengine.api.datastore.Key)
 
  Hope this helps.
 
  On Mon, Nov 16, 2009 at 4:29 PM, Todd Vierling t...@duh.org
  mailto:t...@duh.org wrote:
 
  Test app to reproduce:
 
  http://ancestortest.latest.duh-test.appspot.com/
 
  Source code:
 
 
 http://ancestortest.latest.duh-test.appspot.com/src/ancestortest/AncestorTestServlet.java
 
 http://ancestortest.latest.duh-test.appspot.com/src/ancestortest/UserAccount.java
 
 http://ancestortest.latest.duh-test.appspot.com/src/ancestortest/UserAccountModification.java
 
  This sample code basically creates two UserAccount objects and
  attaches a UserAccountModification to one of them.  Then, a query
  (which, unless the datastore is really slow, should return an empty
  list):
 
  =
 Query q = em.createQuery(select m from
  UserAccountModification m where m.modTime  :newest and m.owner
  = :owner order by modTime desc);
 q.setParameter(newest, System.currentTimeMillis() -
  1L);
 q.setParameter(owner, user1);
 ListUserAccountModification mods = q.getResultList();
  =
 
  I get the following exception:
 
  javax.persistence.PersistenceException: SELECT FROM
  UserAccountModification m WHERE m.modTime  :newest and m.owner
  = :owner ORDER BY modTime desc: Key of parameter value does not have
 a
  parent.
 at
 
 org.datanucleus.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException
  (NucleusJPAHelper.java:264)
 at
 org.datanucleus.jpa.JPAQuery.getResultList(JPAQuery.java:179)
 at
  ancestortest.AncestorTestServlet.doGet(AncestorTestServlet.java:
  46)
 
  I must be missing something here.  The docs for GAE talk about
  ensuring the use of ancestor filters when inside a transaction, for
  instance, and there's the ANCESTOR IS operator in GQL.  However, I
  can't seem to figure out how properly to express this in JPQL (as
  ANCESTOR IS is a syntax error there), and there's no docs that I
 can
  find on doing this in JPA.
 
  The query is meant to find UserAccountModification objects all
  residing under a given owner, which happens to be the ancestor of
  those objects.  Is there a proper expression for this using JPQL?
 
  --
 
  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-java@googlegroups.com
  mailto:google-appengine-java@googlegroups.com.
  To unsubscribe from this group, send email to
  
  google-appengine-java+unsubscr...@googlegroups.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
  
  mailto: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=.
 
 
 
 
 
  --
  Ikai Lan
  Developer Programs Engineer, Google 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=.

 --

 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 

Re: [appengine-java] Ancestor queries in JPQL? / Getting Key of parameter value does not have a parent

2009-11-23 Thread Rusty Wright
I'm thinking of something like a tips and tricks section that goes over these 
extensions as well as JDO/JPA things that might be particularly useful with 
GAE, with examples of how they're useful with GAE.  For example, parent-pk, and 
then in Max's recent article, @PrePersist, @PreUpdate, and the JDO 
StoreCallback interface, which I didn't know about.


Ikai L (Google) wrote:
 I'm happy to add this to the official docs if it isn't clear. I think 
 this makes sense under the JPA section or the section about ancestor 
 queries.
 
 On Sun, Nov 22, 2009 at 11:24 PM, Rusty Wright rwright.li...@gmail.com 
 mailto:rwright.li...@gmail.com wrote:
 
 There are way too many hidden secrets, like this parent-pk query,
 that are buried throughout the App Engine documentation.  It would
 really be nice if these things were more clearly documented.
 
 
 Ikai L (Google) wrote:
   Hey Todd,
  
   There are a few different things you can do here:
  
   1. Use the parent-pk filter. It looks something like this:
  
   query = pm.newQuery(select from Account  +
  
   where parent-pk == keyParam  +
   parameters Key keyParam);
  
  
   There's a groups thread about this here:
  
 
 http://groups.google.com/group/google-appengine-java/browse_thread/thread/97ba3209ec6a65de
  
   and the docs are here:
  
  
 
 http://code.google.com/appengine/docs/java/datastore/transactions.html#Using_Transactions(search
  
   2. Use the low-level API.
  
   com.google.appengine.api.datastore.Query has a constructor that
 takes an
   Ancestor key.
  
 
 http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Query.html#Query(com.google.appengine.api.datastore.Key)
  
   Hope this helps.
  
   On Mon, Nov 16, 2009 at 4:29 PM, Todd Vierling t...@duh.org
 mailto:t...@duh.org
   mailto:t...@duh.org mailto:t...@duh.org wrote:
  
   Test app to reproduce:
  
   http://ancestortest.latest.duh-test.appspot.com/
  
   Source code:
  
  
 
 http://ancestortest.latest.duh-test.appspot.com/src/ancestortest/AncestorTestServlet.java
  
 
 http://ancestortest.latest.duh-test.appspot.com/src/ancestortest/UserAccount.java
  
 
 http://ancestortest.latest.duh-test.appspot.com/src/ancestortest/UserAccountModification.java
  
   This sample code basically creates two UserAccount objects and
   attaches a UserAccountModification to one of them.  Then, a query
   (which, unless the datastore is really slow, should return an
 empty
   list):
  
   =
  Query q = em.createQuery(select m from
   UserAccountModification m where m.modTime  :newest and m.owner
   = :owner order by modTime desc);
  q.setParameter(newest, System.currentTimeMillis() -
   1L);
  q.setParameter(owner, user1);
  ListUserAccountModification mods =
 q.getResultList();
   =
  
   I get the following exception:
  
   javax.persistence.PersistenceException: SELECT FROM
   UserAccountModification m WHERE m.modTime  :newest and m.owner
   = :owner ORDER BY modTime desc: Key of parameter value does
 not have a
   parent.
  at
  
 org.datanucleus.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException
   (NucleusJPAHelper.java:264)
  at
 org.datanucleus.jpa.JPAQuery.getResultList(JPAQuery.java:179)
  at
   ancestortest.AncestorTestServlet.doGet(AncestorTestServlet.java:
   46)
  
   I must be missing something here.  The docs for GAE talk about
   ensuring the use of ancestor filters when inside a
 transaction, for
   instance, and there's the ANCESTOR IS operator in GQL.
  However, I
   can't seem to figure out how properly to express this in JPQL (as
   ANCESTOR IS is a syntax error there), and there's no docs
 that I can
   find on doing this in JPA.
  
   The query is meant to find UserAccountModification objects all
   residing under a given owner, which happens to be the
 ancestor of
   those objects.  Is there a proper expression for this using JPQL?
  
   --
  
   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-java@googlegroups.com
 mailto:google-appengine-java@googlegroups.com
   mailto:google-appengine-java@googlegroups.com
 mailto:google-appengine-java@googlegroups.com.
 

Re: [appengine-java] JDO x JPA

2009-11-23 Thread Rusty Wright
If you look at Max's examples and test code he does everything in both JDO and 
JPA, so it seems to me that it's a coin toss.

I went with JDO because I heard that it's not as strongly oriented to 
relational sql databases.


Rafael Reuber wrote:
 Hi there,
  
 What's the better suport for GAE, JDO or JPA? I see many examples in 
 JDO so I think that it have the better support.
 
 -- 
 Rafael Reuber
 MSN/Gtalk: psico.in...@gmail.com mailto:psico.in...@gmail.com
 
 --
 
 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=.

--

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




Re: [appengine-java] Help:I can't make a object persistent completely.

2009-11-23 Thread Rusty Wright
Try

@Persistent(defaultFetchGroup = true)

on anything that's not listed in the Core Value Types table on 
http://code.google.com/appengine/docs/java/datastore/dataclasses.html


Jolam wrote:
 This is the object:
 ___
 
 @PersistenceCapable(identityType = IdentityType.APPLICATION,
 detachable = true)
 public class Client implements java.io.Serializable {
 
 
 
   @Persistent
   private ArrayListOneService serviceRecords;
 
   @Persistent
   private ArrayListOneService serviceNow;
 
   @Persistent
   private String remarks;
 
 ..
 
   public ArrayListOneService getServiceRecords() {
   return serviceRecords;
   }
 
   public void setServiceRecords(ArrayListOneService serviceRecords) {
   this.serviceRecords.clear();
   for (int i = 0; i  serviceRecords.size(); i++) {
   this.serviceRecords.add(serviceRecords.get(i));
   }
   }
 
   public ArrayListOneService getServiceNow() {
   return serviceNow;
   }
 
   public void setServiceNow(ArrayListOneService serviceNow) {
   this.serviceNow.clear();
   for (int i = 0; i  serviceRecords.size(); i++) {
   this.serviceNow.add(serviceNow.get(i));
 
 when i try to make this kind of Object pesistent like this:
 ___
 
 ArrayListOneService serviceNow = new ArrayListOneService();
 serviceNow.add(oneservice);
 client.setServiceNow(serviceNow);
 ___
 
 the ArrayList serviceNow in the Object doesn't contains another
 object oneservice i want to add into the ArrayListserviceNow.
 
 p.s. my english is bad and if it makes u confused because of my poor
 expression,i beg your pardon.
 
 --
 
 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=.
 
 

--

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




[appengine-java] Re: Now available: JDO/JPA preview release with inheritance support

2009-11-23 Thread R. A.
 http://datanucleus-appengine.googlecode.com/files/appengine-orm-1.0.4.RC1.zip
 This release provides support for inheritance of native datastore types and 
 embedded classes.

Can't get inheritance to run. Tested on *-1.0.3 and *-1.0.4.RC1.
Without AbstractEntity, 2 entities with OneToMany relationship works
perfectly. Is it the problem with  Key id type? NullPointerException
is thrown when i access child list element:

public void test() {
ListParentEntity parents = tdao.load();
for (ParentEntity pe : parents) {
ListChildEntity childs = pe.getChilds();
System.out.println(.. childs.size:  + childs.size());
for(ChildEntity ce : childs) { // - NPE
}
}
}

@Entity
@MappedSuperclass
public abstract class AbstractEntity {

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

private String name;
...
}

@Entity
public class ParentEntity extends AbstractEntity {

@OneToMany(mappedBy=parent, cascade=CascadeType.ALL)
private ListChildEntity childs;
...
}

@Entity
public class ChildEntity extends AbstractEntity {

private Long value;

@ManyToOne
private ParentEntity parent;
...
}

Nov 23, 2009 8:20:34 PM com.google.apphosting.utils.jetty.JettyLogger
warn
WARNING: Nested in
org.springframework.web.util.NestedServletException: Request
processing failed; nested exception is java.lang.NullPointerException:
java.lang.NullPointerException
at
org.datanucleus.store.mapped.mapping.PersistenceCapableMapping.getObjectForApplicationIdentity
(PersistenceCapableMapping.java:971)
at
org.datanucleus.store.mapped.mapping.PersistenceCapableMapping.getObject
(PersistenceCapableMapping.java:720)
at
org.datanucleus.store.appengine.DatastoreRelationFieldManager.lookupParent
(DatastoreRelationFieldManager.java:309)
at
org.datanucleus.store.appengine.DatastoreRelationFieldManager.fetchRelationField
(DatastoreRelationFieldManager.java:289)
at
org.datanucleus.store.appengine.DatastoreFieldManager.fetchObjectField
(DatastoreFieldManager.java:271)
at org.datanucleus.state.AbstractStateManager.replacingObjectField
(AbstractStateManager.java:1197)
at gae.test.ChildEntity.jdoReplaceField(ChildEntity.java)
at gae.test.AbstractEntity.jdoReplaceFields(AbstractEntity.java)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields
(JDOStateManagerImpl.java:2772)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields
(JDOStateManagerImpl.java:2791)
at
org.datanucleus.store.appengine.DatastorePersistenceHandler.fetchObject
(DatastorePersistenceHandler.java:443)
at org.datanucleus.store.appengine.query.DatastoreQuery.entityToPojo
(DatastoreQuery.java:433)
at
org.datanucleus.store.appengine.DatastoreElementContainerStoreSpecialization.getChildren
(DatastoreElementContainerStoreSpecialization.java:103)
at org.datanucleus.store.appengine.DatastoreFKListStore.listIterator
(DatastoreFKListStore.java:47)
at
org.datanucleus.store.mapped.scostore.AbstractListStore.listIterator
(AbstractListStore.java:84)
at org.datanucleus.store.mapped.scostore.AbstractListStore.iterator
(AbstractListStore.java:74)
at org.datanucleus.sco.backed.List.loadFromStore(List.java:241)
at org.datanucleus.sco.backed.List.iterator(List.java:507)
at java.util.AbstractCollection.toString(AbstractCollection.java:414)
at java.lang.String.valueOf(String.java:2826)
at java.lang.StringBuilder.append(StringBuilder.java:115)
at gae.test.TestServiceImpl.openParentsWithChilds
(TestServiceImpl.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke
(Runtime.java:100)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection
(AopUtils.java:307)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint
(ReflectiveMethodInvocation.java:183)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
(ReflectiveMethodInvocation.java:150)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke
(TransactionInterceptor.java:107)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke
(JdkDynamicAopProxy.java:202)
at $Proxy28.openParentsWithChilds(Unknown Source)
at gae.test.TestController.test(TestController.java:17)
at 

Re: [appengine-java] Re: convert JDO query to JPA

2009-11-23 Thread Ikai L (Google)
Here's a video from Google I/O last year about complex data modeling on App
Engine. It talks a little bit about how we do indexing underneath the hood:

http://www.youtube.com/watch?v=AgaL6NGpkB8

Look for an upcoming article about the subject. App Engine Datastore is
built on top of BigTable. It's not really voodoo, the properties are
simply indexed. The reason it may seem strange is because coming from an
RDBMS world, this just isn't something that is done. In App Engine, however,
the way indexing works allows us to be flexible in what data types it allows
us to surface and the ways we allow users to query those data types.

Here are my example classes:

Dog.java: http://pastie.org/711953
ListFriendsServlet.java: http://pastie.org/711959

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

import javax.persistence.*;
import java.util.List;
import java.util.LinkedList;

@Entity
public class Dog {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key key;

@Basic
private String name;

@Basic
private int age;

private ListKey dogFriends;

public Dog(String name, int age) {
this.name = name;
this.age = age;
}

public Dog() {
this(Lucky, 5);
}

public Key getKey() {
return key;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public void addDogFriend(Key key){
if (this.dogFriends == null) {
this.dogFriends = new LinkedListKey();
}

this.dogFriends.add(key);
}

public ListKey getDogFriends(){
return this.dogFriends;
}


@Override
public String toString() {
return Dog{ +
key= + key +
, name=' + name + '\'' +
, age= + age +
'}';
}
}

import EMF;
import Dog;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

public class ListFriendsServlet extends HttpServlet {

@SuppressWarnings(unchecked)
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String keyString = request.getParameter(friend);
Key key = KeyFactory.stringToKey(keyString);

EntityManager em = EMF.get().createEntityManager();
PrintWriter out = response.getWriter();

ListDog dogs;

try {

Query query = em.createQuery(SELECT FROM Dog WHERE
dogFriends = :key);
query.setParameter(key, key);
dogs = (ListDog) query.getResultList();

dogs.size();  // Do this so we can eager load the list and
close the EMF
} finally {
em.close();
}

out.println(Listing dogs);
for(Dog dog : dogs) {
out.println(dog);
}
}
}



The other classes describe adding Dogs and Dog friends and aren't terribly
interesting.

On Sun, Nov 22, 2009 at 2:49 PM, lp lucio.picc...@gmail.com wrote:

  Can you post the JPA version of your entity?

 @Entity
 public class Friend {


  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Key key;

  private String lastName;

  public int crud;

  private String firstName;

  @Basic
  private CollectionKey friends;


  I've just built something similar, and if I pass a Key to:
 
  query.setParameter(key, key);
 
  This works correctly, though if I pass the String key to it
 
  query.setParameter(key, someLongString);


 what was ur query? was the query to filter on a collection?
 i have set the parameters against primitive members successfully but
 not against collection members.

  It returns an empty list. Could this be what is happening?

 no.i just retested my code to make sure i hadnt messed up. i am
 definitely using a Key not a string.

 //JPA
 javax.persistence.Query query = em.createQuery(select from Friend f
 where f.friends=:key);
 query.setParameter(key, user2.getKey());

 return list of 0

 using the *same* JPA entity code the JDO works fine

 //JDO
 javax.jdo.Query query = pm.newQuery(Friend.class);
 Key myKey = user2.getKey();
 query.declareParameters(com.google.appengine.api.datastore.Key
 myKey);
 query.setFilter(friends == myKey);
 query.setOrdering(lastName ASC, firstName ASC);
 ListFriend friendList = (ListFriend) query.execute(myKey);

 return correct list

 Q1 can u post your JPA code so i can see what u have done differently?

 Q2. is mixing JPA and JDO 

Re: [appengine-java] Re: Now available: JDO/JPA preview release with inheritance support

2009-11-23 Thread Max Ross (Google)
Thanks for the report!  I've made a lot of fixes since the RC1 build but
they're not backwards-compatible with the 1.2.6 SDK, so unfortunately I
can't release them until the next SDK is out.  Your test case works for me
with my latest build so this will behave correctly in the next release.

Thanks,
Max

On Mon, Nov 23, 2009 at 1:56 PM, R. A. ramanauskas.ado...@gmail.com wrote:

 
 http://datanucleus-appengine.googlecode.com/files/appengine-orm-1.0.4.RC1.zip
  This release provides support for inheritance of native datastore types
 and embedded classes.

 Can't get inheritance to run. Tested on *-1.0.3 and *-1.0.4.RC1.
 Without AbstractEntity, 2 entities with OneToMany relationship works
 perfectly. Is it the problem with  Key id type? NullPointerException
 is thrown when i access child list element:

 public void test() {
ListParentEntity parents = tdao.load();
for (ParentEntity pe : parents) {
ListChildEntity childs = pe.getChilds();
System.out.println(.. childs.size:  + childs.size());
for(ChildEntity ce : childs) { // - NPE
}
}
 }

 @Entity
 @MappedSuperclass
 public abstract class AbstractEntity {

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

private String name;
 ...
 }

 @Entity
 public class ParentEntity extends AbstractEntity {

@OneToMany(mappedBy=parent, cascade=CascadeType.ALL)
private ListChildEntity childs;
 ...
 }

 @Entity
 public class ChildEntity extends AbstractEntity {

private Long value;

@ManyToOne
private ParentEntity parent;
 ...
 }

 Nov 23, 2009 8:20:34 PM com.google.apphosting.utils.jetty.JettyLogger
 warn
 WARNING: Nested in
 org.springframework.web.util.NestedServletException: Request
 processing failed; nested exception is java.lang.NullPointerException:
 java.lang.NullPointerException
at

 org.datanucleus.store.mapped.mapping.PersistenceCapableMapping.getObjectForApplicationIdentity
 (PersistenceCapableMapping.java:971)
at
 org.datanucleus.store.mapped.mapping.PersistenceCapableMapping.getObject
 (PersistenceCapableMapping.java:720)
at
 org.datanucleus.store.appengine.DatastoreRelationFieldManager.lookupParent
 (DatastoreRelationFieldManager.java:309)
at

 org.datanucleus.store.appengine.DatastoreRelationFieldManager.fetchRelationField
 (DatastoreRelationFieldManager.java:289)
at
 org.datanucleus.store.appengine.DatastoreFieldManager.fetchObjectField
 (DatastoreFieldManager.java:271)
at org.datanucleus.state.AbstractStateManager.replacingObjectField
 (AbstractStateManager.java:1197)
at gae.test.ChildEntity.jdoReplaceField(ChildEntity.java)
at gae.test.AbstractEntity.jdoReplaceFields(AbstractEntity.java)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields
 (JDOStateManagerImpl.java:2772)
at org.datanucleus.state.JDOStateManagerImpl.replaceFields
 (JDOStateManagerImpl.java:2791)
at
 org.datanucleus.store.appengine.DatastorePersistenceHandler.fetchObject
 (DatastorePersistenceHandler.java:443)
at org.datanucleus.store.appengine.query.DatastoreQuery.entityToPojo
 (DatastoreQuery.java:433)
at

 org.datanucleus.store.appengine.DatastoreElementContainerStoreSpecialization.getChildren
 (DatastoreElementContainerStoreSpecialization.java:103)
at org.datanucleus.store.appengine.DatastoreFKListStore.listIterator
 (DatastoreFKListStore.java:47)
at
 org.datanucleus.store.mapped.scostore.AbstractListStore.listIterator
 (AbstractListStore.java:84)
at org.datanucleus.store.mapped.scostore.AbstractListStore.iterator
 (AbstractListStore.java:74)
at org.datanucleus.sco.backed.List.loadFromStore(List.java:241)
at org.datanucleus.sco.backed.List.iterator(List.java:507)
at
 java.util.AbstractCollection.toString(AbstractCollection.java:414)
at java.lang.String.valueOf(String.java:2826)
at java.lang.StringBuilder.append(StringBuilder.java:115)
at gae.test.TestServiceImpl.openParentsWithChilds
 (TestServiceImpl.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
 (NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
 (DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
 com.google.appengine.tools.development.agent.runtime.Runtime.invoke
 (Runtime.java:100)
at
 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection
 (AopUtils.java:307)
at

 org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint
 (ReflectiveMethodInvocation.java:183)
at
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed
 (ReflectiveMethodInvocation.java:150)
at
 

[appengine-java] Persistable JDO object - low-level entity?

2009-11-23 Thread Erem
Hey all,

Are there any built in tools in the API to translate a managed JDO
object into a low-level Entity?

I want to do a batch put of some JDO-managed objects and some low-
level Entities. If I could translate JDO-managed objects into bigtable
Entities, I could do this in one call to the low-level API rather than
one call to persistenceManager.makePersistentAll(Collection) and
another to datastoreService.put(IterableEntity).

Thanks for the help!

Erem

--

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




[appengine-java] Re: Help With Images In Java

2009-11-23 Thread mably
Found this doc on Google, it might help you :

http://balusc.blogspot.com/2007/04/imageservlet.html#ImageServletServingFromDatabase

On 20 nov, 05:09, java-dev sehgal@gmail.com wrote:
 hi all,

 I need some help with images in appengine using java. Now I have
 sucessfully uploaded an image file and stored it to the datastore. I
 am also able to read back the stored image (as a byte[] array). Now
 the issue is, how do I display this image in my jsp page?

 ***

 //gets the image file Object  from the read data d
 ImageFile f = d.getImg();

 //gets the byte array of this image
 byte[] imb = f.getImg();

 //futile attempt to display this image
 for(int i=0; iimb.length; i++)
 out.println(imb[i]);

 ***
 The above code displays the raw bytes on the jsp pageHow can I get
 this to display the image itself?

 Any help would be greatly appreciated..

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




[appengine-java] Re: bulkloader dump and restore

2009-11-23 Thread lent
Thanks Ikai.  The approach you suggested for exporting the key field
worked for me.

Len

On Nov 19, 5:36 pm, Ikai L (Google) ika...@google.com wrote:
 Len,

 I assume you are doing this by having different application versions for a
 Python application and Java application as documented here:

 http://googleappengine.blogspot.com/2009/06/10-things-you-probably-di...

 Then redefining your Java data class in Python in your Exporter class and
 passing a string similar to this to appcfg.py:

 appcfg.py --server=python.latest.YOURAPPID.appspot.com download_data APPDIR
  --filename=output.csv --kind=Thing --config_file=APPDIR/thing_exporter.py

 There's a trick you'll need to export the key. Here's my Thing.java 
 (http://pastie.org/706983):

 import com.google.appengine.api.datastore.Key;
 import javax.jdo.annotations.*;

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

     @PrimaryKey
     @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
     private Key key;

     @Persistent
     private String name;

     @Persistent
     private int number;

     public Thing(String name, int number) {
         this.name = name;
         this.number = number;
     }

     public Key getKey() {
         return key;
     }

     public String getName() {
         return name;
     }

     public void setName(String name) {
         this.name = name;
     }

     public int getNumber() {
         return number;
     }

     public void setNumber(int number) {
         this.number = number;
     }

 }

 Here's the corresponding Python exporter code (http://pastie.org/706981):

 from google.appengine.ext import db
 from google.appengine.tools import bulkloader

 class Thing(db.Model):
   name = db.StringProperty()
   number = db.IntegerProperty()

 def AddKeys(entity_generator):
     for entity in entity_generator:
         entity['key'] = entity.key()
         yield entity

 class ThingExporter(bulkloader.Exporter):
     def __init__(self):
         bulkloader.Exporter.__init__(self, 'Thing',
                                      [('key', str, None),
                    ('name', str, None),
                                       ('number', str, None)
                                      ])

     def output_entities(self, entity_generator):
         bulkloader.Exporter.output_entities(self, AddKeys(entity_generator))

 exporters = [ThingExporter]

 The magic here is in the AddKey that you define. You add the key field to
 the objects in each iteration of your loop exporting an entity.





 On Fri, Nov 13, 2009 at 4:15 PM, lent lentakeu...@gmail.com wrote:
  Hello,

  I got python bulkloader upload data and download data working with
  loader and exporter for my java app.  Do the bulkloader dump and
  restore options work when used with java app?  They don't seem to work
  for me.  I get an error like:
  BadRequestError: app xxx cannot access app bulkload.latest.xxx's data

  When doing download data, how can I get the id field exported, i.e.
  what do you need to specify in the exporter to export the id field?  I
  tried field names such as key and id (of type db.Key) but they didn't
  work.

  Regards,
  Len

  --

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

 --
 Ikai Lan
 Developer Programs Engineer, Google App Engine- Hide quoted text -

 - Show quoted text -

--

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




[appengine-java] app engine session variable

2009-11-23 Thread Don
Hi,

I am trying to store an object in the session in servlet by
req.getSession().setAttribute(portofolio, portofolio);

where portofolio is an object with about 10variables and functions.

However, App engine behaves strangely when I do this, so I resorted to
just saving strings into session attributes.

Is this the correct behaviour? (where I could not set arbitrary object
except string into session attributes?)

Many 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] InputStream read returning -1, but avalible btyes correct ?

2009-11-23 Thread Toby Reyelts
FYI a couple of notes:

1) InputStream.available() only tells you how many bytes can be read without
blocking. From its specification:

It is never correct to use the return value of this method to allocate a
 buffer intended to hold all data in this stream.


Just don't use it.

2) InputStream.read() is not guaranteed to fill your buffer. You must always
use it in a loop.

On Mon, Nov 23, 2009 at 5:50 PM, Ikai L (Google) ika...@google.com wrote:

 What are you posting? This code works for me:

 public class TestPostServlet extends HttpServlet {

 protected void doPost(HttpServletRequest request, HttpServletResponse
 response) throws ServletException, IOException {
 InputStream in = request.getInputStream();

 int size = in.available();
 byte[] body = new byte[size];
 int status = in.read(body);
 in.close();

 response.getWriter().println(Status of read:  + status +  Size:
  + size);
 response.getWriter().println(Got your post:  + new String(body));

 }
 }

 What mechanism are you using to POST to your application? Is it a browser
 form or a custom client?


 On Sat, Nov 21, 2009 at 12:37 PM, Bourke Floyd IV chb...@gmail.comwrote:

 //This was working before I overhauled the authentication of my app
 //I'm trying to store the body of a Http POST as Text, I also plan on
 doing a Blob version
 //The maxLength is returning the correct size, but the read is
 returning -1 instead of properly
 //updating the body byte array

 //...

 InputStream httpIn = req.getInputStream();
 byte[] body = new byte[httpIn.available()];
 httpIn.read(body);

 Text myPostBody = new Text(new String(body)); //wasteful maybe? but
 should work

 //...

 //My old code was roughly the same

 //...

 int maxLength = req.getContentLength();
 byte[] body = new byte[maxLength];

 InputStream httpIn = req.getInputStream();
 httpIn.read(body, 0, maxLength);

 String  myPostBody = new String(body); //wasteful maybe? but should
 work

 //...

 --

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





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


--

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: InputStream read returning -1, but avalible btyes correct ?

2009-11-23 Thread Bourke Floyd IV
//I figured out the problem. Example case: POST Request from a webpage
with 2 text fields (userEmail = '5...@gmail.com', and favCar =
'corvette')
//If I use
String email = req.getParameter(userEmail)

//and then try to get the whole body of the POST

InputStream inputStream = req.getInputStream();
if (inputStream != null) {
 byte[] body = new byte[inputStream.available()];
 inputStream.read(body);
 String body = new String(body);
}

//body = 
//but if I comment out the use of ANY getParameter Call, I get body
fine.
//Also, the reverse also holds true

//if you get the body using the InputStream, then try to use
getParameter
//then all of your getParameters will return null

//I don't know if this is by design or a bug because I'm not
experienced Java Programmer

-Bourke



On Nov 23, 5:50 pm, Ikai L (Google) ika...@google.com wrote:
 What are you posting? This code works for me:

 public class TestPostServlet extends HttpServlet {

     protected void doPost(HttpServletRequest request, HttpServletResponse
 response) throws ServletException, IOException {
         InputStream in = request.getInputStream();

         int size = in.available();
         byte[] body = new byte[size];
         int status = in.read(body);
         in.close();

         response.getWriter().println(Status of read:  + status +  Size: 
 + size);
         response.getWriter().println(Got your post:  + new String(body));

     }

 }

 What mechanism are you using to POST to your application? Is it a browser
 form or a custom client?

 On Sat, Nov 21, 2009 at 12:37 PM, Bourke Floyd IV chb...@gmail.com wrote:





  //This was working before I overhauled the authentication of my app
  //I'm trying to store the body of a Http POST as Text, I also plan on
  doing a Blob version
  //The maxLength is returning the correct size, but the read is
  returning -1 instead of properly
  //updating the body byte array

  //...

  InputStream httpIn = req.getInputStream();
  byte[] body = new byte[httpIn.available()];
  httpIn.read(body);

  Text myPostBody = new Text(new String(body)); //wasteful maybe? but
  should work

  //...

  //My old code was roughly the same

  //...

  int maxLength = req.getContentLength();
  byte[] body = new byte[maxLength];

  InputStream httpIn = req.getInputStream();
  httpIn.read(body, 0, maxLength);

  String  myPostBody = new String(body); //wasteful maybe? but should
  work

  //...

  --

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

 --
 Ikai Lan
 Developer Programs Engineer, Google 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] JDO x JPA

2009-11-23 Thread Timothy Spear
For GAE it developers it will be mostly a matter of preference. There  
are purists on both sides of the fence, although from a market share  
perspective I think JPA has the upper hand. I base this on the number  
of recent articles, support by commercial application containers, and  
job applicants.

Personally, I prefer the annotations of JPA. To me a Class is an  
Entity (which is a noun) while JDO use Persistable which is not even a  
real word, and if it was, would be an adjective. :-)


Tim

On Nov 23, 2009, at 2:42 PM, Ikai L (Google) wrote:

 Both JDO and JPA support are built on top of the low-level API:

 http://code.google.com/appengine/docs/java/datastore/overview.html

 Anecdotally, I see more articles about JDO on App Engine, but my  
 experience
 has been that there are more *general* JPA articles lying around,  
 though
 they may not be applicable since they are more geared towards  
 relational
 databases. There are also a number of developers simply building
 applications using the Low Level API.

 On Sat, Nov 21, 2009 at 9:56 AM, Rafael Reuber  
 psico.in...@gmail.comwrote:

 Hi there,

What's the better suport for GAE, JDO or JPA? I see many  
 examples in
 JDO so I think that it have the better support.

 --
 Rafael Reuber
 MSN/Gtalk: psico.in...@gmail.com

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




 -- 
 Ikai Lan
 Developer Programs Engineer, Google 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-java@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= 
 .



--

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: convert JDO query to JPA

2009-11-23 Thread lp

         EntityManager em = EMF.get().createEntityManager();
         PrintWriter out = response.getWriter();

         ListDog dogs;

         try {

             Query query = em.createQuery(SELECT FROM Dog WHERE
 dogFriends = :key);
             query.setParameter(key, key);
             dogs = (ListDog) query.getResultList();

             dogs.size();  // Do this so we can eager load the list and

solve it!

running your code in my unit test i still get a 0 size result list.

*until* i added the following in my unittest

Dog user1 = new Dog()

//blah blah
em.merge(user1);

em.close();  -- needed to close existing em

em = getEnityManager();

//query now executes correctly


it seems that the entity manager is not working as i expected.
by doing em.close after making objects persistent and then getting new
em, allowed the em.query to execute correctly.

i am not clear of why the em behaviours like that, given the em.find()
seem to find the correct object.

any ideas?

-lp

--

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: convert JDO query to JPA

2009-11-23 Thread lp

 EntityManager em = EMF.get().createEntityManager();
 PrintWriter out = response.getWriter();

 ListDog dogs;

 try {

 Query query = em.createQuery(SELECT FROM Dog WHERE
 dogFriends = :key);
 query.setParameter(key, key);
 dogs = (ListDog) query.getResultList();

 dogs.size();  // Do this so we can eager load the list and

solve it!

running your code in my unit test i still get a 0 size result list.

*until* i added the following in my unittest

Dog user1 = new Dog()

//blah blah
em.merge(user1);

em.close();  -- needed to close existing em

em = getEnityManager();

//query now executes correctly


it seems that the entity manager is not working as i expected.
by doing em.close after making objects persistent and then getting new
em, allowed the em.query to execute correctly.

i am not clear of why the em behaviours like that, given the em.find()
seem to find the correct object.

any ideas?

-lp

--

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] How to remove property of java object(POJO) with safty?

2009-11-23 Thread sea
Environment :GAE for java, JPA

I defined a java object(POJO) and stored some data in it. But later I
found a property of that java object(POJO) was useless,
and there was no data in that property.So I removed that property, but
that caused a big problem, the data in that
java object(POJO) can not be displayed by program.

So could you tell me how to deal with it? I want to remove the useless
property of java object(POJO) , and want original data can be
displayed by program.

Thanks a lot.

--

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: problem with using session.getAttribute()

2009-11-23 Thread Steph
I also have the same issue when retrieving session objects from a
servlet filter, and running in the local sandbox.

On Nov 21, 10:11 pm, Sanjay sanjaykumar.pa...@gmail.com wrote:
 Did you solve this problem? I am facing exactly same problem, it would
 be nice if you could share the solution if you found one.

 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.




[appengine-java] Re: JDO x JPA

2009-11-23 Thread datanucleus
http://www.datanucleus.org/products/accessplatform_2_0/persistence_api.html

--

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: app engine session variable

2009-11-23 Thread Jeune
What strange behaviour exactly? I think you should serialize the
portfolio object before you should store it to session.
Another thing is, IMO you should not store too many things to the
session. But that's me. I'd like to know other people's thoughts

On Nov 24, 9:37 am, Don lydonchan...@gmail.com wrote:
 Hi,

 I am trying to store an object in the session in servlet by
 req.getSession().setAttribute(portofolio, portofolio);

 where portofolio is an object with about 10variables and functions.

 However, App engine behaves strangely when I do this, so I resorted to
 just saving strings into session attributes.

 Is this the correct behaviour? (where I could not set arbitrary object
 except string into session attributes?)

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