I can understand the frustration. For GAE we have our transactions at
the dao level unless we know that it can be at the service level.
Since we are banking on the data becoming eventually consistent, we do
not have transaction related problems right now.
And, since they are at the dao level we do not get into the issue you
mentioned. Not sure if you can move your transactions a level down.

On Sep 28, 10:20 am, "David C. Hicks" <dhi...@i-hicks.org> wrote:
>   I am most accustomed to defining my transactions at the service level,
> so that multiple DAO might be involved in a single transaction.  I do
> realize that the DataNucleus datastore has some peculiar behavior with
> regard to transactions.  I'm still learning the ins and outs, though.
>
> My test setup is essentially identical to what is posted in the blog
> entry you posted.  In one test, I create an entity, then I read it
> back.  Finally, I perform a query against one field which returns a
> collection containing the single entity, but when I call size() on the
> collection it throws the infamous "Object Manager has been closed"
> exception.  I can only assume that my test has no transaction wrapper,
> thus allowing the EntityManager to be closed very early in my test.  I
> just don't see how I can reasonably test anything if the Object Manager
> won't remain open long enough to verify the results.
>
> Dave
>
> On 09/28/2010 01:07 AM, Vikas Hazrati wrote:
>
>
>
> > Have you tried running the dao code in a transaction? Is your store
> > and find happening in different transactions? Also you should take a
> > note of "Unlike with most databases, queries and gets inside a
> > datastore transaction do not see the results of previous writes inside
> > that transaction. Specifically, if an entity is modified or deleted
> > within a transaction, a query or get will return the original version
> > of the entity as of the beginning of the transaction, or nothing if
> > the entity did not exist then." from the docs
> >http://code.google.com/appengine/docs/java/datastore/transactions.html
>
> > btw, for unit testing with the local datastore we have information on
> > our blog here
>
> >http://thoughts.inphina.com/2010/06/28/unit-testing-maven-based-jpa-a...
>
> > Regards | Vikas
>
> > On Sep 28, 4:35 am, "David C. Hicks"<dhi...@i-hicks.org>  wrote:
> >>    I have followed the instructions I found and set up the
> >> LocalServiceTestHelper to act as a datastore.  I can save an entity in
> >> the datastore and re-read it, but then I make a call to search for all
> >> entities that match a criteria.  The resulting List<entity>  collection
> >> throws an "Object Manager has been closed" exception as soon as I try to
> >> get the size().
>
> >> I understand that this is resolved in a real runtime environment by
> >> using the OpenEntityManagerInView filter, but in a testing environment
> >> the filter isn't in play.  I've been trying most of the day to figure
> >> out how to keep the object manager open through the life of a test, but
> >> damned if I can get it.  Anyone know of a good example somewhere?
>
> >> Thanks,
> >> Dave

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

Reply via email to