On Tue, Nov 6, 2012 at 9:19 PM, Vidal B. <vidalborro
...@gmail.com> wrote:
> Ok. Follow-up questions...
> Given the following code:
> Objectify objectifyInstance = ObjectifyService.factory().begin();
> 1) The javadoc for begin() indicates:
> The default options are:
> - Do NOT begin a transaction.
> - *Do NOT use a session cache. *
> - DO use a global cache.
> - Use STRONG consistency.
> - Apply no deadline to calls.
> But the wiki page says the session cache is enabled automatically. Is the
> javadoc just out-of-date?
Ooops, obsolete javadoc. Fixed.
2) And just to double-check, is the above code the proper way to start a
> new session (e.g. in a servlet's doPost() method) when running in
> threadsafe-mode?
The proper way is to always call ofy(), the static method on
ObjectifyService. You will always get the right session. You should not
call begin() directly in your code.
All of the current documentation examples show the ofy() pattern.
3) When using multiple Objectify instances, is there anything
> (resource-wise) we need to deal with when an instance is about to be
> discarded (e.g. at the end of a doPost() method)?
No, there is nothing you need to do to close session. But unless you
really know what you're doing (say, running two transactions in parallel)
you shouldn't even be asking this question - just use ofy() every time you
want to access Objectify. If you need to escape a transaction temporarily,
use ofy().transactionless().load()...etc
Jeff
BTW: 4.0 beta 1 should be in Maven Central tomorrow. Just waiting for
sonatype to approve the release.