From: Gavin_King/Cirrus%<CI...@ci...> - 2002-03-03 08:44:43
|
> Another simple question then: how do I "lock" something? If I was doing > plain old JDBC, I'd use a "SELECT ... FOR UPDATE" with or without a > NOWAIT option. Okay, I almost brought this up myself earlier. I've been concerned about it for a while. My understanding is that most databases will lock rows automatically when necessary (according to the transaction isolation level). Hibernate never uses FOR UPDATE because some databases (eg. Sybase) don't even allow this clause on a select. However, I sort of thought that some other platforms (eg. MySQL) might need it. Does anyone know more about this than me? It will be simple enough to make hibernate always select for update on those databases which need it, or we can add findForUpdate() or loadForUpdate() to the API. Are there other times when you *need* to use a select for update? ie. times when you *need* to grab a write lock immediately rather than escalating to a write lock when we issue an UPDATE? This, for sure, is something I need a really definite answer on before we go out of beta.... thanks for raising it Paul. |