[appengine-java] How to model this kind of relationship? (Trackbacks)

2011-10-05 Thread Thiago Rossi
r_id: 2}, {date_time: '', visited_profile_id: 2, visitor_id: 2}, {date_time: '', visited_profile_id: 3, visitor_id: 2}] But it seemed very RDMS. I thought then about: Profile - visitors: [a collection of keys] profile: { visitors: [1, 2, 3], name: "Thiago", bio: "...&quo

Re: [appengine-java] JDO: how to add a child without the collection

2011-07-04 Thread Thiago Rossi
Thanks! Well, in JDO you can do: Query q = pm.newQuery("select id from " + MyClass.class.getName()); I think __key__ can work too, but not sure. On 4 July 2011 19:09, jMotta wrote: > Thiago, > > Nowadays the amount of documentation and features of both interfaces are > a

Re: [appengine-java] Re: JDO: how to add a child without the collection

2011-07-04 Thread Thiago Rossi
True. I had forgotten about the unowned relationships, but I think again I will need to retrieve the collections in order to add the new Key, right? Of course it's much better to retrieve a collection of keys than a collection of entities. And maybe making the relationship from the LoginHistory to

Re: [appengine-java] How to update a record in Google Apps data store

2011-07-04 Thread Thiago Rossi
You just need to retrieve it, change it and close the persistence manager. No makePersistent method needed. For example: public void updateEmployeeTitle(User user, String newTitle) { PersistenceManager pm = PMF.get().getPersistenceManager(); try { Employee e = pm.getObjectById(

[appengine-java] JDO: how to add a child without the collection

2011-07-04 Thread Thiago
need to do this: User user = pm.getObjectById(User.class.getName(), "thiago"); LoginHistory loginHistory = new LoginHistory(now); loginHistory.setKey(user.getKey().getChild(LoginHistory.class.getName(), now.getTime()); user.getLoginHistory(loginHistory); pm.close(); I loginHostory has t

[appengine-java] When/Is @Embedded necessary?

2011-01-08 Thread Thiago
I noticed, at least I couldn't see anything different, that if I omit this annotation in a field, the behavior of the Persistence Manager is the same when it comes to make an entity persistent. I'm talking about fields which type are marked as @EmbeddedOnly. @PersistenceCapable(detachable = "true"

[appengine-java] Datastore: Keys

2011-01-06 Thread Thiago
Hi, everybody. I'm new to GAE and I've been reading a few books/tutorial about it. However, something is still not clear to me. It always describes that a key would have a reference to the entity parent. So, if I have the following entity User, when it is persisted the Image will have a key saying