Thanks. Great response!
On Fri, Oct 21, 2011 at 8:53 PM, Jeff Schnitzer <[email protected]> wrote:
> Implicit transactions are a separate issue (and a terrible idea).
>
> When the low-level api starts a transaction, it stores this txn as a thread
> local. The get()/put()/etc methods that don't have a transaction are
> effectively this logic:
>
> Entity get(Key key) {
> if (there is a thread local txn)
> return this.get(theThreadLocalTxn, key);
> else
> return this.get(null, key);
> }
>
> Passing in null is the only way to guarantee that you're making a call
> without a transaction.
>
> This thread-local transaction stuff helps support the JDO/JPA plugin but
> it's a bit of a mess if you use the low-level API. My advice is not to use
> it at all - avoid the methods that don't have a txn parameter and pass null
> in when you don't have/want a transaction. Hide this behind a facade.
>
> Jeff
>
> On Fri, Oct 21, 2011 at 5:23 AM, Mos <[email protected]> wrote:
>
>> I'm a bit confused:
>> Following some examples and looking at the API of the DatastoreService
>> it seems to be required to use the overloaded methods whenever
>> transactional behavior is required.
>> In other words: The current transaction needs to be specified on put() und
>> get() methods like this:
>>
>> Transaction txn = datastore.beginTransaction();
>> // ....
>> Entity employee = datastore.get(txn, employeeKey);
>> employee.setProperty("vacationDays", 10);
>> datastore.put(txn, employee);
>> txn.commit();
>>
>> But when looking at the official Google docs, there seems to be no need
>> for specifying the
>> transaction explicitly:
>>
>> http://code.google.com/intl/de-DE/appengine/docs/java/datastore/transactions.html
>> ?
>>
>> Can someone explain this? Is this an issue with "implicit transaction"
>> behavior? How does it work?
>>
>> Thanks a lot
>> Mos
>>
>>
>> --
>> 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.
>
--
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.