[appengine-java] Re: Not able to save child object in one-to-many relationship
Thanks for the info. I looked at the issue and many other people having problem of saving child object in a one-to-many relation. I am new to this and I don't understand completely. Is there any work- around to save a child object. If anyone can show me an example, I appreciate. This is really frustrating as this is basic functionality in any relational data. In my case, Employee object already exists and I want to create a new appointment and associate with the employee object. If there is a different way of doing this, please help. This has taken quite a lot of time and if this is not available in GWT, I don't think I can use Google apps for the development of our application. I appreciate any help. Thanks, Ravi On Aug 27, 1:51 am, Frederik Pfisterer wrote: > Your problem seems to be related to this open gwt > issue:http://code.google.com/p/google-web-toolkit/issues/detail?id=4976 > > Please star the issue to raise its attention. The workaround is not > using 1:n relationships with GWT + GAE + JDO. > > Cheers, > Fred > > On 26 Aug., 23:12, hampole wrote: > > > I am trying to develop GAE application. I am using the latest GWT > > SDK(2.0.4) AND App Engine SDK(1.3.6) on Eclipse3.4. I am having > > problem insavinga childobject"Appointment" and the parentobject > > is "Employee". Each Employee has many appointments and and each > > appointment has one employee associated with. I have pasted the Client > > code and the server code here. Please help and see what I am missing > > here. I tried many different ways without success. When I retrieve the > > appointments, the employee is always null. I appreciate any help or > > some example that I can try. Thanks. > > > //Client code > > public class AppointmentCreateWidget extends Composite { > > > private static AppointmentCreateWidgetUiBinder uiBinder = GWT > > .create(AppointmentCreateWidgetUiBinder.class); > > > interface AppointmentCreateWidgetUiBinder extends > > UiBinder { > > } > > > @UiField Button btnSaveAppointment; > > @UiField TextBox tbxSubject; > > @UiField ListBox lbxRoom; > > @UiField ListBox lbxHost; > > @UiField DateBox dbAppointStartDate; > > @UiField DateBox dbAppointEndDate; > > @UiField ListBox lbxStartTimeHr; > > @UiField ListBox lbxEndTimeHr; > > @UiField ListBox lbxStartTimeMi; > > @UiField ListBox lbxEndTimeMi; > > > private final AppointmentServiceAsync appointService = > > (AppointmentServiceAsync) GWT.create(AppointmentService.class); > > private final List visitors = new ArrayList(); > > > public AppointmentCreateWidget() { > > initWidget(uiBinder.createAndBindUi(this)) > > } > > > @UiHandler("btnSaveAppointment") > > void onClick(ClickEvent e) { > > addAppointment(); > > } > > > private void addAppointment() { > > String subject = tbxSubject.getText().toUpperCase().trim(); > > Date startdate = dbAppointStartDate.getValue(); > > Date enddate = dbAppointEndDate.getValue(); > > String starttime = > > lbxStartTimeHr.getValue(lbxStartTimeHr.getSelectedIndex()).toString() > > + > > lbxStartTimeMi.getValue(lbxStartTimeMi.getSelectedIndex()); > > String endtime = > > lbxEndTimeHr.getValue(lbxEndTimeHr.getSelectedIndex()).toString() + > > lbxEndTimeMi.getValue(lbxEndTimeMi.getSelectedIndex()); > > String room = > > lbxRoom.getValue(lbxRoom.getSelectedIndex()).toString(); > > String key = lbxHost.getValue(lbxHost.getSelectedIndex()); > > DateTimeFormat dateFormat = DateTimeFormat.getShortDateFormat(); > > > try { > > createAppointment(subject, startdate, enddate, > > starttime, > > endtime, key, visitors); > > } > > catch(Exception ex) { > > Window.alert("Save Appointment failed: " + ex.toString()); > > } > > } > > > private void createAppointment(String subject, Date startdate, Date > > enddate, String starttime, String endtime, String empID, List > > visitor) { > > appointService.addAppointment(subject,startdate, enddate, > > starttime, endtime, empID, visitor, new AsyncCallback() { > > public void onFailure(Throwable error) { > > Window.alert("Unable to create Appointment." + > > error.getMessage()); > > } > > public void onSuccess(Void ignore) { > > } > > }); > > } > > > } > > > //ServiceImpl > > public class AppointmentServiceImpl extends RemoteServiceServlet > > implements AppointmentService { > > /** > > * > > */ > > private static final long serialVersionUID = 1L; > > > public void addAppointment(String subject, Date appointStartDate, > >
[appengine-java] How to debug blobstore uploads with 405
Hello all, I am trying to upload to the blobstore from an installed c# client, not a browser. So far, I've only tried the development server... I can see in the datastore viewer that the blobs are being correctly created because there are corresponding blobinfo objects that correctly reflect the uploaded data, but my client gets a 405 response from the blobstore and my "success url" never gets invoked. How does one go about debugging this? I don't see any kind of output from the blobstore on the eclipse console, so I'm not sure where to start. Thanks, Mike -- 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: Security issue with Google account on Gwt-client site
The User object contains just the email address of the user. Just send it to the client in a String and null if the user is not logged in. Then you can just check with (username != null) if the user is logged in. Uwe On Aug 27, 6:25 pm, androidDeveloper wrote: > Hi all, > > as written in > threadhttp://groups.google.com/group/google-appengine-java/browse_thread/th... > > it is not possible to use the Google Account class > (com.google.appengine.api.users.User) on GWT-client site. > A solution would be to create a DTO to transfer the data to the > client. > > My Question: > Is it allowed to transfer the data from Google account objects to > client, particularly the userId? > > I try to implement some kind of checkSession method, which brings a > Google account to client site if a user is logged in. The Google > account is then stored on client site in a member variable for further > use. -- 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 Not Persisting Object and No Error That I can find
I have the following code: public String addBankAccountTransaction(String lBankAccountTransactionJson) { log.info("\n\nBankAccountActions::addBankAccountTransaction:start"); GsonBuilder gsonb = new GsonBuilder(); DateDeserializer ds = new DateDeserializer(); gsonb.registerTypeAdapter(Date.class, ds); GoogleKeyDeserializer gkd = new GoogleKeyDeserializer(); gsonb.registerTypeAdapter(Key.class, gkd); Gson gson = gsonb.create(); BankAccountTransaction lBankAccountTransaction = gson.fromJson(lBankAccountTransactionJson, BankAccountTransaction.class); PersistenceManager pm = PMF.getSecond().getPersistenceManager(); Transaction tx = pm.currentTransaction(); try { tx.begin(); pm.makePersistent(lBankAccountTransaction); tx.commit(); log.info("BankAccountActions::addBankAccountTransaction:lBankAccountTransaction.getKey::Committed transction"); } catch (Exception e) { log.info("BankAccountActions::addBankAccountTransaction:Exception " + e.getStackTrace()); } finally { if (tx.isActive()) { log.info("BankAccountActions::addBankAccountTransaction:lBankAccountTransaction.getKey::transction FAILED!"); tx.rollback(); } pm.close(); } log.info("BankAccountActions::addBankAccountTransaction:lBankAccountTransaction.getKey() " + lBankAccountTransaction.getKey()); log.info("BankAccountActions::getBankAccounts:end\n\n"); return "ok"; } It throws no error, but the makePersistent doesn't seem to complete/ work and the key is subsequently null and it doesn't show up in the datastoreviewer so I assume it's not there. Maybe I don't have logging setup correctly, my logging.properties looks like: java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter # Set the default logging level for INFO loggers to WARNING .level = INFO # Set the default logging level for ORM, specificFINEy, to INFO DataNucleus.JDO.level=INFO DataNucleus.Persistence.level=FINE DataNucleus.Cache.level=INFO DataNucleus.MetaData.level=INFO DataNucleus.General.level=INFO DataNucleus.Utility.level=INFO DataNucleus.Transaction.level=FINE DataNucleus.Datastore.level=FINE DataNucleus.ClassLoading.level=INFO DataNucleus.Plugin.level=INFO DataNucleus.ValueGeneration.level=INFO DataNucleus.Enhancer.level=INFO DataNucleus.SchemaTool.level=INFO Any ideas why this isn't saving and why I don't see any errors? I am using SDK 1.3.6. 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.
[appengine-java] Security issue with Google account on Gwt-client site
Hi all, as written in thread http://groups.google.com/group/google-appengine-java/browse_thread/thread/3033d853fc0a7209/3e56400d7859387d?lnk=gst&q=google+account+gwt+client+#3e56400d7859387d it is not possible to use the Google Account class (com.google.appengine.api.users.User) on GWT-client site. A solution would be to create a DTO to transfer the data to the client. My Question: Is it allowed to transfer the data from Google account objects to client, particularly the userId? I try to implement some kind of checkSession method, which brings a Google account to client site if a user is logged in. The Google account is then stored on client site in a member variable for further use. -- 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: Null parent on some children objects
Hi Frederik! Sorry for my ignorance, I tougth that the right way to save a Second object was: pm.makePersistent(mySecondObject); myFirstObject.getList().add(mySecondObject); pm.makePersistent(myFirstObject); while if I understood your explanation I don't have to invoke pm.makePersistent() on mySeconObject, is it? I also put in all my getter methods a check on null object, in that way: class Second { @Persistent @PrimaryKey Key id; @Persistent First owner; @Persistent List tags; First getOwner() { if (owner==null) owner = new First(); return owner; } List getTags() { if (tags==null) tags= new ArrayList(); return tags; } ... } Do I have to remove all the check of the type if (obj==null) obj=new...? Thank you very much for your help! Best cghersi On 27 Ago, 10:58, Frederik Pfisterer wrote: > Hi, > > the problem is this line: > owner = new First(); > > Beware that the only way you should ever store a Second object is: > myFirstObject.getList().add(mySecondObject); > pm.makePersistent(myFirstObject); > > since Second.owner is mapped it's automatically populated by the > persistance manager. > > Hope this helps, > Fred > > On 26 Aug., 17:38, cghersi wrote: > > > > > Hi Diego, > > > thank you but unfortunately I strictly followed what stated in that > > page, and the result is the problem I posted!! > > > Any other hint? > > > Thank you very much, > > Best > > Cghersi > > > On 26 Ago, 16:09, Diego Fernandes wrote: > > > > Hi, > > > i may find something > > > herehttp://code.google.com/intl/en/appengine/docs/java/datastore/relation... > > > > []'s > > > Diego > > > > On 26 ago, 04:42, cghersi wrote: > > > > > Hi everybody, > > > > > I'm struggling with a strange problem with JDO. > > > > I've got two PersistenCapable classes, one having a Collection of > > > > objects of the second, something like this: > > > > > class First { > > > > �...@persistent > > > > �...@primarykey > > > > Long id; > > > > > �...@persistent(mappedby="owner") > > > > ArrayList list = new ArrayList(); > > > > > ArrayList getList() { > > > > if (list == null) > > > > list=new ArrayList(); > > > > return list; > > > > } > > > > > ... > > > > > } > > > > > class Second { > > > > �...@persistent > > > > �...@primarykey > > > > Key id; > > > > > �...@persistent > > > > First owner; > > > > > First getOwner() { > > > > if (owner==null) > > > > owner = new First(); > > > > return owner; > > > > > ... > > > > > } > > > > > In another class I need to print the owner of all my First objects, so > > > > I do: > > > > First obj = ...; > > > > ArrayList list = obj.getList(); > > > > for (Second s : list) { > > > > System.out.println(s.getOwner()); > > > > > } > > > > > In this loop, I find some Second object having null owner, and I > > > > cannot understand why. > > > > Now I have several questions about my data modelling: > > > > 1) Do I need to mark any field with (defaultFetchGroup = "true") > > > > annotation? > > > > 2) Does the check on null object (e.g. if (owner==null) owner = new > > > > First();) in the getter methods results in any strange behavior? > > > > 3) Does the assignment on definition of objects (e.g. > > > > ArrayList list = new ArrayList();) results in any > > > > strange behavior? > > > > 4) Do I need to add any other annotation to owner field of Second > > > > class? > > > > > Thank you very much for your help!! > > > > Best regards > > > > cghersi -- 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: [Perhaps OT] Oracle vs. Google : Java still a viable language?
On Aug 27, 4:54 pm, Romain Pelisse wrote: > You could definitely argue that Red Hat is yet an other "greedy corporate > owner" but it is one that has always understood the importance of "openess". I don't mind companies making bucket-loads of money just so long as they don't do it (directly or indirectly) at the expense of the end- users and developers (by trying to shut down competition by hook or by crook). > Nonetheless, it seems that Oracle is harming Java and even if Java can > certainly survives it, it's not a good thing anyway. Yeah, I think most would agree that Oracle ownership of Java isn't good. Regards, markVgti -- 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: [Perhaps OT] Oracle vs. Google : Java still a viable language?
> > I am worried about not just Java on GAE (though that's the more > immediate concern), but also about Java's future in general. Don't > want to be stuck with a proprietary language that has bad stewardship > and a belligerent, short-sighted, greedy corporate owner. > Well, as long as Red Hat/JBoss stays what it is now, I think Java is safe. Red Hat has become an important member of the Java community since they acquired JBoss and they were (I think) one of the first contributors to OpenJDK. All the products of JBoss rely on Java, so if, at some point, Oracle tries to really close down Java, my guess is Red Hat will then fork OpenJDK. You could definitely argue that Red Hat is yet an other "greedy corporate owner" but it is one that has always understood the importance of "openess". Nonetheless, it seems that Oracle is harming Java and even if Java can certainly survives it, it's not a good thing anyway. -- Romain PELISSE, "The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it" -- Terry Pratchett http://belaran.eu/ -- 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: [Perhaps OT] Oracle vs. Google : Java still a viable language?
Thanks for sharing your thoughts Shawn. IANAL either :-). I am worried about not just Java on GAE (though that's the more immediate concern), but also about Java's future in general. Don't want to be stuck with a proprietary language that has bad stewardship and a belligerent, short-sighted, greedy corporate owner. Also, Java on GAE seems to be a secondary citizen to Python :-)... that makes me question even more whether I should be learning Python ;-). On Aug 27, 2:13 pm, Shawn Brown wrote: > > Motivation: I am at the early stages of implementing a web app on GAE > > using Java, but if I need to switch to Python, I shouldn't delay it > > any more. > > Anyway, what do you guys think? > > IANAL but you asked so here goes. I think you are fine using java on GAE. > > My guess is that since appengine is a derivative of OpenJDK that the > (SE) patent grant holds for appengine as long as it doesn't implement > new core functionality which the OpenJDK does not. In such a case, I > don't believe the patent grant holds. You'd have to read the grant > more closely or an analysis of it to know whether only partially > implementing it carries the grant. Even if Oracle were to argue > partial implementation does not, I believe the GPL2 combined with a > patent grant for that code means effectively that Oracle can not say > what people do with the GPL2 code, only that new functionality may not > carry the protection. > > So, were GAE to fork OpenJDK and implement new core java classes (this > does not mean new classes using java but a re-implementation of java > with new functionality), then it's possible that we may see patent > issues. Given the issues with Android though, I suspect Google will > stay in the clear and I do not believe the GAE SDK does this. > > That said, if you try to take the SDK jars and set up an equivalent of > GAE that runs on your phone (note: I am not talking about an app on a > phone that connects to GAE, I am talking about *running* a GAE > instance on a mobile phone) then perhaps you may have trouble as > Oracle reserved the rights to mobile devices for non-GPL versions of > Java. Nobody would or could ever do that I think, and so am sure it > won't ever be an issue. > > Don't listen to me though. Really don't. > > Shawn -- 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: Best practice modeling a 1:n user-relationship with List properties
Hi, >be aware of the lazy loading that JDO performs Question 1: Do we have lazy loading on lists of Core Value Types like Google account (com.google.appengine.api.users.User) too? Question 2a: If a myAppUser has for example 1000 friends. Then with List I would have to read the referenced myAppUser's for each userId in the list to get the nicknames. To get all nicknames in one query I would have to put a where condition on the userId of each user and concatenate the conditions with "Or, ||". I read, that a query has a limit of 30 "Ors". So I would have to split the Query in 30-packages. Is this a good solution or would it be better to hold the nicknames in a separate denormalized list in myAppUser? (Problem with the denormalized nickname-list would be, that I would have to update the list each time a user changes his nickname) Question 2b: Would it be too much overhead to read the nicknames in a separate Query for each userId? Or is this a bad solution because of the datastore calling overhead? Question 3: Is it possible to put a query-filter on a subfield of a Google account user object (for example the nickname-field)? In my tests I was not successful... On 27 Aug., 11:13, Frederik Pfisterer wrote: > Hi, > > my recommendation would be to use List . In your reasoning for > query 2 be aware of the lazy loading that JDO performs in the > background to retrieve the related objects. > Query one and two are similar (if nickname is a field of MyAppUser): > Query q = pm.newQuery(MyAppUser.class); > q.setFilter("userKey == userKeyParam"); > q.declareParameters("String userKeyParam"); > > q.execute(appUserKey); > > will give you a list of his friends. > > Hope this helps, > Fred > > On 24 Aug., 12:53, androidDeveloper wrote: > > > Hi all, > > > I am trying to model a 1:n relationship between different "myAppUser" > > instances on Google App Engines Datastore. MyAppUser has a reference > > to 0...n other users (friends). > > MyAppUser is currently defined as showed below: > > > class MyAppUser { > > @PrimaryKey > > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > > @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = > > "true") > > private String primaryKey; > > > @Persistent > > private User user > > > @Persistent > > private List friendsList; Or alternative private List > > friendsList; > > ... > > > } > > > I have two queries: > > Query 1: I want to select all MyAppUsers where a specific User is in > > the friendsList. > > Query 2: I want to get all nicknames of the friends of a specific > > MyAppUser. This can be achieved by getting a MyAppsUser by id and then > > calling for each user user.getNickname(). > > > Question query 1: Is a query with a filter on "List friendsList" > > faster or slower than a query with a filter on "List > > friendsList" or is it equal? > > > For query 2 I would say that a "List friendsList" is faster, > > because I have direct access to the nicknames. With only the id stored > > in the friendsList, I have to make another query for each friend in > > the list to get his nickname. > > -- 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: DatastoreService.getCurrentTransaction() throws NoSuchElementException even after PersistenceManager.currentTransaction().begin()
Thanks Simon. I think I have all the test jar files that might be needed: appengine-testing.jar appengine-api.jar appengine-api-labs.jar appengine-api-stubs.jar appengine-local-runtime.jar The same failure happens in development mode too in which no test jar files are needed. Any more hints appreciated. Arnold. On Aug 27, 11:41 am, Simon wrote: > Check to make sure you have all of the test Jar files in your > classpath - I remember having this error and I was missing one of them > (can't remember which one I'm afraid...) > > On Aug 26, 10:38 pm, Arnold wrote: > > > > > When using JDO persistence manager to begin a transaction, > > DatastoreService().getCurrentTransaction() seems to fail. > > > A unit test: > > -- > > public class TransactionTest{ > > private final LocalServiceTestHelper helper = > > new LocalServiceTestHelper(new > > LocalDatastoreServiceTestConfig()); > > > @Before > > public void setUp() { > > helper.setUp(); > > } > > > @After > > public void tearDown() { > > helper.tearDown(); > > } > > > @Test > > public void test(){ > > PersistenceManager pm = PMF.get().getPersistenceManager(); > > Transaction tx = pm.currentTransaction(); > > try{ > > tx.begin(); > > > DatastoreServiceFactory.getDatastoreService().getCurrentTransaction(); > > > tx.commit(); > > }finally{ > > if(pm.currentTransaction().isActive()){ > > pm.currentTransaction().rollback(); > > } > > pm.close(); > > } > > > }} > > > -- > > > The test fails with stack trace: > > -- > > java.lang.IllegalStateException: java.util.NoSuchElementException > > at > > com.google.appengine.api.datastore.TransactionStackImpl.peek(TransactionSta > > ckImpl.java: > > 70) > > at > > com.google.appengine.api.datastore.DatastoreServiceImpl.getCurrentTransacti > > on(DatastoreServiceImpl.java: > > 307) > > at TransactionTest.test(TransactionTest.java:37) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > > 39) > > at > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp > > l.java: > > 25) > > at java.lang.reflect.Method.invoke(Method.java:597) > > at org.junit.runners.model.FrameworkMethod > > $1.runReflectiveCall(FrameworkMethod.java:44) > > at > > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable. > > java: > > 15) > > at > > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.j > > ava: > > 41) > > at > > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.ja > > va: > > 20) > > at > > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java: > > 28) > > at > > org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java: > > 31) > > at > > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.ja > > va: > > 73) > > at > > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.ja > > va: > > 46) > > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180) > > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41) > > at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173) > > at > > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java: > > 28) > > at > > org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java: > > 31) > > at org.junit.runners.ParentRunner.run(ParentRunner.java:220) > > at > > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestRe > > ference.java: > > 46) > > at > > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java: > > 38) > > at > > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestR > > unner.java: > > 467) > > at > > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestR > > unner.java: > > 683) > > at > > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner > > .java: > > 390) > > at > > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunne > > r.java: > > 197) > > Caused by: java.util.NoSuchElementException > > at java.util.LinkedList.getFirst(LinkedList.java:109) > > at > > com.google.appengine.api.datastore.TransactionStackImpl.peek(T
Re: [appengine-java] [Perhaps OT] Oracle vs. Google : Java still a viable language?
> Motivation: I am at the early stages of implementing a web app on GAE > using Java, but if I need to switch to Python, I shouldn't delay it > any more. > Anyway, what do you guys think? IANAL but you asked so here goes. I think you are fine using java on GAE. My guess is that since appengine is a derivative of OpenJDK that the (SE) patent grant holds for appengine as long as it doesn't implement new core functionality which the OpenJDK does not. In such a case, I don't believe the patent grant holds. You'd have to read the grant more closely or an analysis of it to know whether only partially implementing it carries the grant. Even if Oracle were to argue partial implementation does not, I believe the GPL2 combined with a patent grant for that code means effectively that Oracle can not say what people do with the GPL2 code, only that new functionality may not carry the protection. So, were GAE to fork OpenJDK and implement new core java classes (this does not mean new classes using java but a re-implementation of java with new functionality), then it's possible that we may see patent issues. Given the issues with Android though, I suspect Google will stay in the clear and I do not believe the GAE SDK does this. That said, if you try to take the SDK jars and set up an equivalent of GAE that runs on your phone (note: I am not talking about an app on a phone that connects to GAE, I am talking about *running* a GAE instance on a mobile phone) then perhaps you may have trouble as Oracle reserved the rights to mobile devices for non-GPL versions of Java. Nobody would or could ever do that I think, and so am sure it won't ever be an issue. Don't listen to me though. Really don't. Shawn -- 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: Best practice modeling a 1:n user-relationship with List properties
Hi, my recommendation would be to use List . In your reasoning for query 2 be aware of the lazy loading that JDO performs in the background to retrieve the related objects. Query one and two are similar (if nickname is a field of MyAppUser): Query q = pm.newQuery(MyAppUser.class); q.setFilter("userKey == userKeyParam"); q.declareParameters("String userKeyParam"); q.execute(appUserKey); will give you a list of his friends. Hope this helps, Fred On 24 Aug., 12:53, androidDeveloper wrote: > Hi all, > > I am trying to model a 1:n relationship between different "myAppUser" > instances on Google App Engines Datastore. MyAppUser has a reference > to 0...n other users (friends). > MyAppUser is currently defined as showed below: > > class MyAppUser { > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = > "true") > private String primaryKey; > > @Persistent > private User user > > @Persistent > private List friendsList; Or alternative private List > friendsList; > ... > > } > > I have two queries: > Query 1: I want to select all MyAppUsers where a specific User is in > the friendsList. > Query 2: I want to get all nicknames of the friends of a specific > MyAppUser. This can be achieved by getting a MyAppsUser by id and then > calling for each user user.getNickname(). > > Question query 1: Is a query with a filter on "List friendsList" > faster or slower than a query with a filter on "List > friendsList" or is it equal? > > For query 2 I would say that a "List friendsList" is faster, > because I have direct access to the nicknames. With only the id stored > in the friendsList, I have to make another query for each friend in > the list to get his nickname. -- 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: The title of email displays wrongly in localization
Have try encoding to quoted printable this way: msg.setSubject(MimeUtility.encodeText(_subject, "UTF-8", "Q")); http://groups.google.com/group/google-appengine-java/browse_thread/thread/7479beb80a97992f/36156bbdee1b9fa2?lnk=gst&q=encode+subject#36156bbdee1b9fa2 On Aug 26, 3:23 am, Tony wrote: > Hello, > > I have a problem to dispay the title of email if it includes Chinese. > I tried: > [1] > ... > String title = "测试标题"; > message.setSubject(title); > ... > And > [2] > ... > String title = "测试标题"; > title = MimeUtility.encodeText(title); > message.setSubject(title); > ... > > Both titles are displayed as "?". If the program works in > Tomcat (without GAE/GWT), the 2nd is ok. > > Please let me know, if you have any idea to handle the title > localization issue? > > Thanks in advance, > Tony -- 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: Null parent on some children objects
Hi, the problem is this line: owner = new First(); Beware that the only way you should ever store a Second object is: myFirstObject.getList().add(mySecondObject); pm.makePersistent(myFirstObject); since Second.owner is mapped it's automatically populated by the persistance manager. Hope this helps, Fred On 26 Aug., 17:38, cghersi wrote: > Hi Diego, > > thank you but unfortunately I strictly followed what stated in that > page, and the result is the problem I posted!! > > Any other hint? > > Thank you very much, > Best > Cghersi > > On 26 Ago, 16:09, Diego Fernandes wrote: > > > Hi, > > i may find something > > herehttp://code.google.com/intl/en/appengine/docs/java/datastore/relation... > > > []'s > > Diego > > > On 26 ago, 04:42, cghersi wrote: > > > > Hi everybody, > > > > I'm struggling with a strange problem with JDO. > > > I've got two PersistenCapable classes, one having a Collection of > > > objects of the second, something like this: > > > > class First { > > > �...@persistent > > > �...@primarykey > > > Long id; > > > > �...@persistent(mappedby="owner") > > > ArrayList list = new ArrayList(); > > > > ArrayList getList() { > > > if (list == null) > > > list=new ArrayList(); > > > return list; > > > } > > > > ... > > > > } > > > > class Second { > > > �...@persistent > > > �...@primarykey > > > Key id; > > > > �...@persistent > > > First owner; > > > > First getOwner() { > > > if (owner==null) > > > owner = new First(); > > > return owner; > > > > ... > > > > } > > > > In another class I need to print the owner of all my First objects, so > > > I do: > > > First obj = ...; > > > ArrayList list = obj.getList(); > > > for (Second s : list) { > > > System.out.println(s.getOwner()); > > > > } > > > > In this loop, I find some Second object having null owner, and I > > > cannot understand why. > > > Now I have several questions about my data modelling: > > > 1) Do I need to mark any field with (defaultFetchGroup = "true") > > > annotation? > > > 2) Does the check on null object (e.g. if (owner==null) owner = new > > > First();) in the getter methods results in any strange behavior? > > > 3) Does the assignment on definition of objects (e.g. > > > ArrayList list = new ArrayList();) results in any > > > strange behavior? > > > 4) Do I need to add any other annotation to owner field of Second > > > class? > > > > Thank you very much for your help!! > > > Best regards > > > cghersi -- 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: Not able to save child object in one-to-many relationship
Your problem seems to be related to this open gwt issue: http://code.google.com/p/google-web-toolkit/issues/detail?id=4976 Please star the issue to raise its attention. The workaround is not using 1:n relationships with GWT + GAE + JDO. Cheers, Fred On 26 Aug., 23:12, hampole wrote: > I am trying to develop GAE application. I am using the latest GWT > SDK(2.0.4) AND App Engine SDK(1.3.6) on Eclipse3.4. I am having > problem in saving a child object "Appointment" and the parent object > is "Employee". Each Employee has many appointments and and each > appointment has one employee associated with. I have pasted the Client > code and the server code here. Please help and see what I am missing > here. I tried many different ways without success. When I retrieve the > appointments, the employee is always null. I appreciate any help or > some example that I can try. Thanks. > > //Client code > public class AppointmentCreateWidget extends Composite { > > private static AppointmentCreateWidgetUiBinder uiBinder = GWT > .create(AppointmentCreateWidgetUiBinder.class); > > interface AppointmentCreateWidgetUiBinder extends > UiBinder { > } > > @UiField Button btnSaveAppointment; > @UiField TextBox tbxSubject; > @UiField ListBox lbxRoom; > @UiField ListBox lbxHost; > @UiField DateBox dbAppointStartDate; > @UiField DateBox dbAppointEndDate; > @UiField ListBox lbxStartTimeHr; > @UiField ListBox lbxEndTimeHr; > @UiField ListBox lbxStartTimeMi; > @UiField ListBox lbxEndTimeMi; > > private final AppointmentServiceAsync appointService = > (AppointmentServiceAsync) GWT.create(AppointmentService.class); > private final List visitors = new ArrayList(); > > public AppointmentCreateWidget() { > initWidget(uiBinder.createAndBindUi(this)) > } > > @UiHandler("btnSaveAppointment") > void onClick(ClickEvent e) { > addAppointment(); > } > > private void addAppointment() { > String subject = tbxSubject.getText().toUpperCase().trim(); > Date startdate = dbAppointStartDate.getValue(); > Date enddate = dbAppointEndDate.getValue(); > String starttime = > lbxStartTimeHr.getValue(lbxStartTimeHr.getSelectedIndex()).toString() > + > lbxStartTimeMi.getValue(lbxStartTimeMi.getSelectedIndex()); > String endtime = > lbxEndTimeHr.getValue(lbxEndTimeHr.getSelectedIndex()).toString() + > lbxEndTimeMi.getValue(lbxEndTimeMi.getSelectedIndex()); > String room = > lbxRoom.getValue(lbxRoom.getSelectedIndex()).toString(); > String key = lbxHost.getValue(lbxHost.getSelectedIndex()); > DateTimeFormat dateFormat = DateTimeFormat.getShortDateFormat(); > > try { > createAppointment(subject, startdate, enddate, starttime, > endtime, key, visitors); > } > catch(Exception ex) { > Window.alert("Save Appointment failed: " + ex.toString()); > } > } > > private void createAppointment(String subject, Date startdate, Date > enddate, String starttime, String endtime, String empID, List > visitor) { > appointService.addAppointment(subject,startdate, enddate, > starttime, endtime, empID, visitor, new AsyncCallback() { > public void onFailure(Throwable error) { > Window.alert("Unable to create Appointment." + > error.getMessage()); > } > public void onSuccess(Void ignore) { > } > }); > } > > } > > //ServiceImpl > public class AppointmentServiceImpl extends RemoteServiceServlet > implements AppointmentService { > /** > * > */ > private static final long serialVersionUID = 1L; > > public void addAppointment(String subject, Date appointStartDate, > Date appointEndDate, String startTime, String endTime, String empID, > List visitors) throws NotLoggedInException { > PersistenceManager pm = getPersistenceManager(); > //get employee > Employee emp = pm.getObjectById(Employee.class, empID); > > Appointment newAppoint = new Appointment(subject, > appointStartDate, appointEndDate, startTime, endTime); > newAppoint.setVisitors(visitors); > newAppoint.setEmployee(emp); > emp.getAppointments().add(newAppoint); > > try { > pm.makePersistent(emp); > } finally { > pm.close(); > } > } > > private PersistenceManager getPersistenceManager() { > return PMF.get().getPersistenceManager(); > } > > } > > //Employee Bean > @PersistenceCapable(identityType = IdentityType.APPLICATION, > detachable = "true") > public class Employee implements IsSerializable, IValidatable { > > @PrimaryKey > @Persistent(valueStrategy = IdGenerator
[appengine-java] Re: DatastoreService.getCurrentTransaction() throws NoSuchElementException even after PersistenceManager.currentTransaction().begin()
Check to make sure you have all of the test Jar files in your classpath - I remember having this error and I was missing one of them (can't remember which one I'm afraid...) On Aug 26, 10:38 pm, Arnold wrote: > When using JDO persistence manager to begin a transaction, > DatastoreService().getCurrentTransaction() seems to fail. > > A unit test: > -- > public class TransactionTest{ > private final LocalServiceTestHelper helper = > new LocalServiceTestHelper(new > LocalDatastoreServiceTestConfig()); > > @Before > public void setUp() { > helper.setUp(); > } > > @After > public void tearDown() { > helper.tearDown(); > } > > @Test > public void test(){ > PersistenceManager pm = PMF.get().getPersistenceManager(); > Transaction tx = pm.currentTransaction(); > try{ > tx.begin(); > > DatastoreServiceFactory.getDatastoreService().getCurrentTransaction(); > > tx.commit(); > }finally{ > if(pm.currentTransaction().isActive()){ > pm.currentTransaction().rollback(); > } > pm.close(); > } > > }} > > -- > > The test fails with stack trace: > -- > java.lang.IllegalStateException: java.util.NoSuchElementException > at > com.google.appengine.api.datastore.TransactionStackImpl.peek(TransactionStackImpl.java: > 70) > at > com.google.appengine.api.datastore.DatastoreServiceImpl.getCurrentTransaction(DatastoreServiceImpl.java: > 307) > at TransactionTest.test(TransactionTest.java:37) > 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 org.junit.runners.model.FrameworkMethod > $1.runReflectiveCall(FrameworkMethod.java:44) > at > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java: > 15) > at > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java: > 41) > at > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java: > 20) > at > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java: > 28) > at > org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java: > 31) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java: > 73) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java: > 46) > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41) > at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173) > at > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java: > 28) > at > org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java: > 31) > at org.junit.runners.ParentRunner.run(ParentRunner.java:220) > at > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java: > 46) > at > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java: > 38) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java: > 467) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java: > 683) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java: > 390) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java: > 197) > Caused by: java.util.NoSuchElementException > at java.util.LinkedList.getFirst(LinkedList.java:109) > at > com.google.appengine.api.datastore.TransactionStackImpl.peek(TransactionStackImpl.java: > 68) > ... 26 more > > -- > > As a result, the example shown here: > > http://code.google.com/appengine/docs/java/taskqueue/overview.html#Ta... > > does not work. > > Can someone help shade some light on what I may be missing? > > 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 gro
[appengine-java] Re: Query result sets are not modifiable
You'll have to do something like the following: - Iterate over the new contact methods and persist them. - Retrieve the Person object. - Iterate over the newly persisted contact methods and add their keys to the Person's list of contact methods At the moment you're just trying to add objects to a filtered result set of random contact methods, which doesn't make much sense :) On Aug 26, 12:54 am, Shaun wrote: > I have no idea how this doesn't seem to come up anywhere when I > search, but for some reason when I try to add an item to a List > that has been pulled out of the datastore I get this error: > > java.lang.UnsupportedOperationException: Query result sets are not > modifiable > at > org.datanucleus.store.query.AbstractQueryResult.add(AbstractQueryResult.java: > 221) > at > com.appointment.actions.ContactActions.updateContactMethods(ContactActions.java: > 1186) > > My code looks like this: > > public List updateContactMethods(List > pPassedContactMethods,List pDatastoreContactMethodKeys) { > > PersistenceManager pm = PMF.get().getPersistenceManager(); > Query query = pm.newQuery(ContactMethod.class); > query.setFilter("key == :keyList"); > query.execute(pDatastoreContactMethodKeys); > List pDataStoreContactMethods = (List) > pm.newQuery(query).execute(pDatastoreContactMethodKeys); > > for (ContactMethod lContactMethod : pPassedContactMethods) { > pDataStoreContactMethods.add(lContactMethod);} > > pm.close(); > return pDataStoreContactMethods; > > } > > The goal is that when someone adds a new ContactMethod the system > picks that up and adds it to the set of Keys reference in that > Person's List contactsmethods to allow the managing of an unowned > relationship. > > Thanks ahead of time for any 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.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
Re: [appengine-java] The title of email displays wrongly in localization
same here: http://code.google.com/p/googleappengine/issues/detail?id=3497 -- 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] appengine dev at offline mode
when I switched off my internet, I got exception following: 27/08/2010 3:09:58 PM com.google.appengine.tools.info.RemoteVersionFactory getVersion INFO: Unable to access https://appengine.google.com/api/updatecheck?runtime=java&release=1.3.6×tamp=1281725222&api_versions=['1.0'] java.net.UnknownHostException: appengine.google.com at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java: 550) at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java: 141) at sun.net.NetworkClient.doConnect(NetworkClient.java:163) at sun.net.www.http.HttpClient.openServer(HttpClient.java:394) at sun.net.www.http.HttpClient.openServer(HttpClient.java:529) at sun.net.www.protocol.https.HttpsClient.(HttpsClient.java: 272) at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:329) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java: 172) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java: 801) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java: 158) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java: 1049) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java: 234) at java.net.URL.openStream(URL.java:1010) at com.google.appengine.tools.info.RemoteVersionFactory.getVersion(RemoteVersionFactory.java: 76) at com.google.appengine.tools.info.UpdateCheck.checkForUpdates(UpdateCheck.java: 99) at com.google.appengine.tools.info.UpdateCheck.doNagScreen(UpdateCheck.java: 174) at com.google.appengine.tools.info.UpdateCheck.maybePrintNagScreen(UpdateCheck.java: 142) at com.google.appengine.tools.development.DevAppServerMain $StartAction.apply(DevAppServerMain.java:150) at com.google.appengine.tools.util.Parser $ParseResult.applyArgs(Parser.java:48) at com.google.appengine.tools.development.DevAppServerMain.(DevAppServerMain.java: 113) at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java: 89) 27/08/2010 3:09:59 PM com.google.apphosting.utils.jetty.JettyLogger info INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger 27/08/2010 3:09:59 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml Is there a way dev at offline mode? wish reply.. -- 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 do update Statement in GQL for Java
Try GQLExt java library: http://audao.spoledge.com/doc-gae-features.html#gqlext Vaclav On Aug 26, 5:10 am, TP Project TP Project wrote: > Hi can any1 teach me how to use update statement in GQL?? > > thanks in advance -- 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.