[appengine-java] Re: JDO embedded object not being initialized after JDO query
IF there won't be anyone answering such a simple question, I take it is not that simple. Or not working, so please take it out of the documentation (googlers). Thanks. I haven't fixed it yet. Still, I produced a stripped-down version that replicates the issue. And I also checked bugs lists, for both appengine and datanucleus-appengine ... no luck -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/dM77KKc4RnAJ. 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=en. import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; import javax.jdo.annotations.Embedded; import javax.jdo.annotations.EmbeddedOnly; import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.PrimaryKey; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import com.google.appengine.api.datastore.Key; import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; import com.google.appengine.tools.development.testing.LocalServiceTestHelper; public class EmbeddedTest { // Nothing special here besides // 'datanucleus.appengine.allowMultipleRelationsOfSameType' = true private static final PersistenceManagerFactory pmfInstance = JDOHelper.getPersistenceManagerFactory(transactions-optional); // Stripped down version, only having an id and embedded object @PersistenceCapable public static class User { @Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY) @PrimaryKey Key id; @Persistent @Embedded UserDetails details; public User (String name) { this.details = new UserDetails(name); } } // The embedded object @PersistenceCapable @EmbeddedOnly public static class UserDetails { @Persistent String name; public UserDetails(String name) { this.name = name; } } LocalServiceTestHelper helper = new LocalServiceTestHelper( new LocalDatastoreServiceTestConfig()); @Before public void setUp () { helper.setUp(); } @After public void tearDown () { helper.tearDown(); } @Test public void shouldHaveEmbeddedInfo () { final String name = nameForTest; final User u = new User (name); PersistenceManager pm = pmfInstance.getPersistenceManager(); final User uPersisted = pm.makePersistent(u); pm.close(); Assert.assertNotNull(uPersisted); Assert.assertNotNull(uPersisted.details); // Make sure id is not null, we will fetch an User entity using it. Assert.assertNotNull(uPersisted.id); pm = pmfInstance.getPersistenceManager(); final User uFetched = pm.getObjectById(User.class, uPersisted.id); Assert.assertNotNull(uFetched); Assert.assertNotNull(uFetched.id); Assert.assertNotNull(uFetched.details); } }
[appengine-java] Re: JDO embedded object not being initialized after JDO query
Thanks for the harsh reply, but I had no intention to be stressful in any way. Just pointed out this example http://code.google.com/appengine/docs/java/datastore/jdo/dataclasses.html#Embedded_Classes is not clear at all. I'll review the spec (350 pages for JDO v3 spec). 2), I don't pass objects between PMs. I just get the object in another PM by its PK, is that wrong (always close the PM after you're done with it?). Besides, when you move away from @PersistenceCapable objects, you're done with JDO lifecycle specs (I can reuse the Key id value without having a PM nearby, no?). Other fields are saved to the specified values without any problems (Integer, String, Key, etc). But again, great suggestion with the JDO specs. Alex. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/_rfWq_U2qh8J. 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=en.
[appengine-java] Re: JDO embedded object not being initialized after JDO query
Things work if I keep the PM open. Still not happy about that, but at least I've narrowed down the issue. Thanks and sorry again. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/PNiETAUVOEQJ. 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=en.
[appengine-java] Re: JDO embedded object not being initialized after JDO query
Still no thoughts? I'm really stuck with this, have googled it, looked over examples (most questions related to collections of embedded objects), but still can't find an answer. What am I doing wrong? -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/tGLBlrxkm0kJ. 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=en.
[appengine-java] Re: JDO embedded object not being initialized after JDO query
I don't persist AccountDetails, I just persist Account that has such an object initialized: class Account { public Account (String name) { this.details = new AccountDetails (name); } } PersistenceManager pm = PMF.get().getPersistenceManager(); Account account = new Account (test); pm.makePersistent (account); I don't see why would I actually need to save by hand AccountDetails, am I wrong? -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/Kt4xJs4aGqAJ. 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=en.
[appengine-java] Re: JDO embedded object not being initialized after JDO query
try { pm.makePersistent (account); } catch (Throwable t) { /* exception handling */ } finally { pm.close (); } Extracted from the actual code. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/xxuEM0DqBWcJ. 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=en.
[appengine-java] Re: JDO embedded object not being initialized after JDO query
Any ideas? -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/alJZCMbNUUwJ. 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=en.
[appengine-java] JDO embedded object not being initialized after JDO query
Hi, I have a really simple domain structure, like this: @PersistenceCapable Account implements Serializable { @Persistent @PrimaryKey Key id; @Persistent @Embedded AccountDetails details; } @PersistenceCapable @EmbeddedOnly AccountDetails implements Serializable { @Persistent String name; } I can successfully save a new Account. However, when I retrieve it, either doing a - (PersistenceManagerFactory).getObjectById - JDO query the object is found, but that property is *always *null. Is something missing in the code above? I have also noticed that @Persistent(serialized=true) fields in embedded classes seem to cause an exception while saving the *Account*. (is this a known issue or I'm doing something wrong again?). Thanks. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/BD_6D5BPe10J. 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=en.
[appengine-java] Re: Discussion for Best Practices For App Engine With Example
This is not quite an example, but a rather complete file listing, along with specs And your question was? Sorry I don't want to be negative, but your post is so long! On Jun 27, 9:39 pm, RAVINDER MAAN rsmaan...@gmail.com wrote: Hello all I am working on a project which has following requirements.Actually this is not real project .I am used to work with relational DB`s and for future projects I want to use GAE.Through this project I just want to learn best ways to use GAE . It is basically implementation of discussion groups(Same as forums on different sites).In the website users can discuss different topics with friends and other users of the website.So I have to implement following features. 1) User can have many friends. 2) Each user can create multiple discussions. 3) Each discussion will have participant in it. 4) If there is any update in the discussion then participants of the discussion will get notifications. 5) A user can observe his friends by adding them to his observed list.if an observed person creates any discussion a notification will be sent to his observers. 6) Any user can view list of his observers and list of users he/she is observing. 7) Every user can create his profile on website .He can put his picture ,title and tags. 8) Every discussion will have profile on website .It will have picture ,title and tags. 9) Any user of the website can search people or discussions based on the tags associated with the users and discussions.For example If user A has 3 tags in his profile like cooking,continental and Asian and user B has cooking and Asian in his tags and there is discussion named D1 on website which has tags continental and chines then if any user search for keyword continental user A and discussion D1 should come as search results. 10) If a user has created a discussion all the participants of that discussion will be added to his work group.For example let us say there are 4 users A,B,C,D and A creates a discussion named D1 and add user B,C in it.then work group of A will have B and C in it. Work group of B will have A and C in it.Work group of C will have A and B in it.Now if user D creates discussion named D2 and add C as participant in it then work group of D will have C in it.work group of C will now have A,B and D in it.In other words work group is list of all the users with whom a user is participating in any discussion. Its GUI will be as below 1) After log in, user Home page will be shown.On the home page there will be right bar and main content area. In the right bar we will show a) His 10 recent active friends along with link to see all his friends list and total count of his friends. b) His 10 recent discussions created by him with link to see list of all discussions created by him and total count of his discussions. c) 10 recent discussion in which he is participant with link to see list of all discussions in which he his participant and total count of his discussions. d) 10 recent active user to whom he is observing along with link to see list of all observed user and total count of user observed. f) 10 recent active user who are observing him along with link to see list of all his observers and total count of users observing. g) 10 recent active users from his work group along with link to see list of all the users in work group.(Work group is list of all the participants of all discussions in which user is participating) and total count of his work group. In the Main Content we will have a) Initially after log in it will display all the notifications of the user. b) If user click on any link in the right bar then result of that action will be displayed in main content. To implement this I have written following entities.I do not know whether it is the best way to do it .Please help me to know how we can improve this . I am planing to keep Discussion , Message , Workgroup , Notification in one entity group. package com.test; import java.io.Serializable; import java.util.Date; import java.util.HashSet; import java.util.Set; import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.PrimaryKey; import com.google.appengine.api.datastore.Key; @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Discussion implements Serializable{ private static final long serialVersionUID = -9115235415573154018L; @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private String title; @Persistent private String createdBy; @Persistent private Date creationDate; @Persistent private String profileImagePath; @Persistent(defaultFetchGroup = true)
[appengine-java] Re: Persisting class hierarchies
Thank you very much for your replies guys, for now that did not help a lot, but I will try to simplify my model. BTW Ikai, great work with GAE :) As far as DAOs are concerned, yes that is what I was saying (for the considered example, have JungleAnimalDAO which would update only the 'breakfast' field, and AnimalDAO which would update all its fields). I will try to simplify the model (and possibly use some boiler plate code, stop being lazy and create some DTOs) Thanks again, Regards, Alex -- 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] Persisting class hierarchies
Hi guys, I need your opinion regarding this issue : The persistence classes get more complex as the application grows and gets more complex. For my question, consider the following example: Animal { long id, float weight, float speed } JungleAnimal extends Animal { ListAnimal breakfast; } Lion extends JungleAnimal { boolean isMale } So we have a simple class hierarchy, everything works with GAE (I have simplified code above and it turned out to not be Java anymore) - Animal implements Serializable, it is annotated with @PersistenceCapable, all fields have @Persistent, etc. So, now that I have this basic framework, I write an insert method for Lion and this method will write all the fields inherited from hierarchy. The question is, did anybody think about having some DAOs for each class, and each of them being concerned with the fields from that class alone (and calling additional DAOs as the fields need to be persisted up in the hierarchy)? Is that even possible? Thanks, I hope everything is clear. I would really appreciate your opinion on this matter, Alex -- 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: Point to application database with JUnit Test
How about this? http://code.google.com/appengine/docs/java/howto/unittesting.html It shows you how to wire the Gae storage to Junit On Dec 1, 1:44 pm, Zenon zeno...@gmail.com wrote: Hi all, I would to point to the application database with MyJUnitTest. I did some experiments but none did succesfull. Any suggest? 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.