digideskio / datanucleus-appengine

Automatically exported from code.google.com/p/datanucleus-appengine
0 stars 0 forks source link

datanucleus.attachSameDatastore doesn't work #297

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Add <property name="datanucleus.attachSameDatastore" value="true"/> to your 
PMF configuration
2. Fetch any detachable entity from the datastore and detach it
3. Attach it back using pm.makePersistent(entity)

What is the expected output? What do you see instead?

With datanucleus.attachSameDatastore set to true, the checking of existence of 
the object in the datastore should be omitted during the attachment process and 
therefore there shouldn't be any datastore calls. However I always get one 
extra datastore_v3.Get.

What version of the product are you using? On what operating system?

I use default GAE SDK 1.7.0

Original issue reported on code.google.com by tobiaspo...@gmail.com on 21 Aug 2012 at 10:20

GoogleCodeExporter commented 8 years ago
Please present a simple testcase, what log entries you get when you attach 
without that setting and what you get with it. In my mind, with GAE you will 
always have a GET to find the Entity that it relates to, but then without the 
testcase that will never be demonstrated. That setting is designed for RDBMS 
obviously.

Original comment by googleco...@yahoo.co.uk on 23 Aug 2012 at 8:32

GoogleCodeExporter commented 8 years ago
I'm sorry I'm very busy right now and this is not a priority, but I will 
definitely post the testcase later. However I don't see why this shouldn't work 
for GAE but maybe I don't understand the purpose of this setting. 

According to the documentation, when the object is about to be attached back, 
DataNucleus first checks if the entity really exists in current datastore. I 
thought this was meant just to avoid mess and inconsistency in the application. 
In my app, I can guarantee that the detached entity has its equivalent in the 
datastore and therefore this check is redundant for me. And I would guess that 
this "check" is nothing more then querying datastore by the key of the detached 
entity. And that's imho the same for GAE and RDBMS. Maybe it's designed for 
RDBMS but it would be really useful for GAE datastore as well.

(Why I need this: I cache some entities in my app and I have to store them in 
detached state. Otherwise the whole entity group, that means including all 
child objects, would be fetched and cached as well. When I get the entity from 
the cache and want to access the child objects, I have to attach the entity 
first. However since the entity already contains everything required for 
running an ancestor query, I don't think it's necessary to call the extra GET.)

Original comment by tobiaspo...@gmail.com on 23 Aug 2012 at 9:17