Don't you need to persist the thread as well as the comment?  It's
hard to analyze your code with such a small sample.  Does addComment
persist the thread? My
 guess is that something is making the transaction fail, probably
cause you are trying to operate on two different entity groups. I
would simply store the comment as it's own entity and when you want
all the comments simply do a query for comments with parentKey ==
ThreadKey.

On Feb 21, 9:30 pm, "Fernando O." <fot...@gmail.com> wrote:
> Hi all.
> First of all I have to admit: I havent read all the docs.
>
> I had a small app running, it basically has this:
> A User:
> @PersistenceCapable(detachable = "true")
> @FetchGroup(name = "_post", members = { @Persistent(name = "posts") })
> public class User implements Serializable{
> @PrimaryKey
> @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> private Key key;
>
> @Persistent(mappedBy = "user", defaultFetchGroup = "true")
> @Element(dependent = "true")
> private List<Post> posts;
> ....}
>
> A thread :
>
> @PersistenceCapable(detachable = "true")
> @FetchGroup(name = "_user", members = { @Persistent(name = "user")})
> public class Thread implements Serializable {
> @PrimaryKey
> @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> private Long key;
>
> @Persistent(defaultFetchGroup = "true")
> @Element(dependent = "true")
> private User user;
> ...
>
> }
>
> So now I want to add comments, each comment will have: the user that made
> the comment, and the thread that it belongs to, and some other fields:
> @PersistenceCapable(detachable = "true")
> public class ThreadComment implements Serializable{
>  @PrimaryKey
> @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> private Key key;
>
> @Persistent(defaultFetchGroup = "true")
> @Element(dependent = "true")
> private User user;
>
> @Persistent(defaultFetchGroup = "true")
> @Element(dependent = "true")
> private Thread thread;
> ...
>
> }
>
> I changed the Thread to include a list of comments:
> @PersistenceCapable(detachable = "true")
> @FetchGroup(name = "_user", members = { @Persistent(name =
> "comments"),@Persistent(name
> = "user")})
> public class Thread implements Serializable {
> ....
>         @Persistent(defaultFetchGroup = "true")
> @Element(dependent = "true")
> private List<ThreadComment> comments;
>
> }
>
> My problem is that meanwhile this works in memory when I try to persist the
> ThreadComment
> PersistenceManager pm = getPMF();
> Transaction tx = pm.currentTransaction();
> tx.begin();
> thread.addComment(comment);
> pm.makePersistent(comment);
> tx.commit();
> pm.close();
>
> the code gets excecuted but I don't see the comment in the database (in fact
> the logs show no db activity either)
> So I don't see an exception, the code gets excecuted but I don't see the
> comment in the DB.
>
> I already have the db with soem threads without comments, this is a "new
> feature"
>
> Any idea of what I'm doing wrong? (please don't say everything :D )
>
> Thanks!
>
> Fernando

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

Reply via email to