- changed status to wontfix
add hibernate's lock() method to Session, including cascade
taken from #292, the final part of "locking" support would be the lock method:
def lock(self, object, lockmode, entity_name=None)
the challenge here is that the lock operation needs to cascade across properties. a normal "cascade" touches each object instance individually, but in this case the lock
operation requires issuing a SELECT ... FOR UPDATE
for all affected instances. its also a "positive" operation meaning all lazy loaders in the cascade chain need to be fired off.
PropertyLoader
would therefore need to have its own lock
method, which in the case that the list of items is not loaded would fire off the lazy loader, adding along the lockmode
argument that would get passed into the lazy load. for items that are eagerly loaded from the parent, those would already have been in the SELECT FOR UPDATE
from the parent (need to study also how FOR UPDATE
interacts with LEFT OUTER JOIN
).
complicating things more is that many of the instances may already be loaded, and some may have already been loaded via a previous lock operation...in which case do we want to "mark" objects in the Session as locked ? this almost seems like it would use a new magic attribute inside of _state
or similar.
so since there has not been a demand for this version of locking (we have basic select for update support in query), and because i think it needs to be approached carefully with probably some thought to how objects in the session can be positively identified as "locked", im pushing this off to 5.0 for now.
Comments (2)
-
reporter -
reporter - removed milestone
Removing milestone: 0.5.0 (automated comment)
- Log in to comment
theres been no user need for this method and we aren't emulating hibernate so closely anymore.