[appengine-java] Forcing update of JPA entity
In my application, I have a fairly large object that has a complex serialised object structure as a member: @Basic @Lob @Column(nullable = false) private ListFoo fooElements; Now, I try to modify a member of fooElements like this: fooElements.get(0).setSomething(...); When I do this, the main entity will not be updated in the datastore since I never actually modified the member itself, only the content of one of the elements in the list. I have two questions: 1) Would I be better off making Foo an @Entity itself? Bear in mind that I have on the order of a few hundred to a thousand or so elements in the list and it is very important that it can be loaded very fast. It is loaded hundreds of times for each update. 2) Regardless of the anser to the first question, is there a way of telling the system that the main entity should be re-persisted? The only solution I have come up with so far is the following: fooElements = new ArrayListFoo(fooElements); In other words, creating a new list which is a copy of the old one. This feels somewhat inefficient, so I'm wondering what the best solution is. Elias -- 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: Forcing update of JPA entity
On 22 Jan, 00:26, datanucleus andy_jeffer...@yahoo.com wrote: Shouldn't make the slightest bit of difference. GAE/J ought to replace that List with a wrapper that intercepts update operations. It hasn't done that.http://code.google.com/p/datanucleus-appengine/issues/detail?id=144c... Thanks for the information. I didn't know about this. However, even if this issue was fixed it wouldn't apply for two reasons: 1) I'm not using relationships to store this list. It's actually serialised as a @Basic member. 2) I'm not actually modifying the list. I'm modifying an element inside the list. Your workarund, to use JDOHelper would be what I need, but I'm not using JDO. I'm using JPA. Is there a similar workaround there? Elias -- 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: Forcing update of JPA entity
On Jan 22, 2:16 pm, datanucleus andy_jeffer...@yahoo.com wrote: Your workarund, to use JDOHelper would be what I need, but I'm not using JDO. I'm using JPA. Is there a similar workaround there? Doesn't make any difference either. JPA (in DataNucleus) uses JDO enhancement, and so marking the field as dirty using a JDO helper method would do the same under JPA. JPA, sadly, doesn't acknowledge such a situation of changing the contents of a serialised field and so provides no mechanism; JDO does. I suppose the most portable way would be to wrap any such members in a thin wrapper class, so that one could force an update by replacing the wrapper but keep the actual content. I will go for your JDO solution in this case though, since this application is being written specifically for GAE. Thanks a lot for your help. Elias -- 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: how to get session id under a Class which doesn't extend HttpServlet?
On 9 Jan, 16:53, Prashant Gupta nextprash...@gmail.com wrote: I tried following code, getting null all the time. public static HttpSession getSession(){ return new ThreadLocalHttpServletRequest().get().getSession(); } You also need to create a filter where you actually put the data in the TheadLocal. I am just about to go out, so I don't actually have time to write the code for you. Sorry about that. Regards, Elias -- 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: how to get session id under a Class which doesn't extend HttpServlet?
On 9 Jan, 01:27, Prashant Gupta nextprash...@gmail.com wrote: I am trying to implement my own user management system, for that I need some way to make session id available to all classes independent of whether it extends HttpServlet or not. I know there is some way to do that but I am not able to find it. Any kind of help would be appreciated. One way to do it is to use a servlet filter to make the user information available through a ThreadLocal instance. That way you can have a single static method that returns the user wherever you are. -- 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.