http://lmgtfy.com/?q=appengine+jdo+%22default+fetch+group%22
On 2 Mar 2010, at 02:50, Gunnar wrote:
I don't jnow what you mean with "look into default fetch group!.
Please explain.
Gunnar
On 1 mar, 19:20, John Patterson <[email protected]> wrote:
Did you look into "default fetch group"?
On 2 Mar 2010, at 01:04, Gunnar wrote:
Hi,
I followed Jakes advice to do e.setList(list) but no change.
I've also stepped through my code, but there is no exception!
Btw I use version 1.3.1 of the SDK.
Gunnar
On 1 mar, 15:28, John Patterson <[email protected]> wrote:
It is unusual that you see no stack trace. Are you sure you are
not
catching it? You could step through the code line by line to see
what
happens after the line with the problem.
Could this be something to do with setting the fetch group to
default? That seems to be the problem with a lot of peoples JDO
code :)
On 1 Mar 2010, at 21:19, Jake wrote:
If I recall, JDO is picky when it comes to being aware of changes
made
to a persisted object. For example, changing fields directly
(object.field = newValue;) doesn't work - you need to use a
getter/
setter (object.setField(newValue);). Perhaps you are encountering
the
same issue here? Does the following type of thing work?
LIst<SubEntity> list = e.getMyList();
SubEntity first = list.remove(0);
list.add(first);
e.setMyList(list);
pm.makePersistent(e);
tx.commit();
Jake
On Feb 28, 11:05 am, Gunnar <[email protected]> wrote:
Hi,
John and Karel, you are right about the placement of the commit
statement.
It worked in the test example because I only had one instance of
MyEntity.
I don't get any exception at all in the Eclipse console!
When I add a second instance of MyEntity if fails with
"Transaction
is
not active" as expected.
Now I've changed the code in the try statement like this, but
still
the first sub entity is lost and no exception is thrown!
(Of cause it would fail it the list is empty.)
List<MyEntity> results = (List<MyEntity>) query.execute();
if (results.iterator().hasNext()) {
tx.begin();
MyEntity e = results.iterator().next();
List<SubEntity> list = e.getMyList();
SubEntity first = list.remove(0);
boolean ok = list.add(first);
if (!ok) {
System.err.println("could not add
first");
}
System.out.println(list);
pm.makePersistent(e);
tx.commit();
}
On 28 Feb, 02:51, John Patterson <[email protected]> wrote:
This should be throwing an exception. The JavaDocs for
Transaction.commit() say
Commits the transaction. Whether this call succeeds or fails,
all
subsequent method invocations on this object will throw
IllegalStateException.
When something does not work as you expect the first place to
look
is
the logs under your application console.
On 28 Feb 2010, at 05:25, Karel Alvarez wrote:
dont you get any exceptions stacktrace in the server
console? it
would help... also you are calling commit() inside the for
loop,
although the transactions is started only once... that would
crash
in the second iteration in a normal db server, I am not sure
what
GAE does with it, in any case I dont think it is what you
intended...
On Sat, Feb 27, 2010 at 2:52 PM, Gunnar <[email protected]>
wrote:
Hi,
I have problem with reordering a List.
I created a test with an entity called MyEntity which have a
List<SubEntity>.
First I persist one instance of MyEntity with a list
containing 3
SubEntity.
This works fine. Then I call a reorder servlet that moves the
first
SubEntity to the last position in the list.
The result is that the first SubEntity is lost and the
datastore
only
contains 2 SubEntity instances.
What can be wrong?
Here is the reorder code:
package com.google.appengine.demo;
import java.io.IOException;
import java.util.List;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@SuppressWarnings("serial")
public class ReorderServlet extends HttpServlet {
@SuppressWarnings("unchecked")
public void doGet(HttpServletRequest req,
HttpServletResponse
resp)
throws IOException {
PersistenceManager pm =
PMF.get().getPersistenceManager();
Query query = pm.newQuery(MyEntity.class);
Transaction tx = pm.currentTransaction();
try {
tx.begin();
List<MyEntity> results =
(List<MyEntity>)
query.execute();
if (results.iterator().hasNext()) {
for (MyEntity e : results) {
List<SubEntity> list =
e.getMyList();
SubEntity first =
list.remove(0);
boolean ok =
list.add(first);
if (!ok) {
System.err.println("could not add first");
}
System.out.println(list);
pm.makePersistent(e);
tx.commit();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (tx.isActive())
tx.rollback();
query.closeAll();
pm.close();
}
resp.setContentType("text/plain");
resp.getWriter().println("reordered");
}
}
--
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 [email protected]
.
To unsubscribe from this group, send email to
[email protected]
.
For more options, visit this group
athttp://groups.google.com/group/google-appengine-java?hl=en
.
--
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 [email protected]
.
To unsubscribe from this group, send email to
[email protected]
.
For more options, visit this group
athttp://groups.google.com/group/google-appengine-java?hl=en
.
--
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 [email protected]
.
To unsubscribe from this group, send email to
[email protected]
.
For more options, visit this group
athttp://groups.google.com/group/google-appengine-java?hl=en
.
--
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 [email protected]
.
To unsubscribe from this group, send email to
[email protected]
.
For more options, visit this group
athttp://groups.google.com/group/google-appengine-java?hl=en
.
--
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 [email protected]
.
To unsubscribe from this group, send email to [email protected]
.
For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en
.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.