samedi 2 juillet 2016

Multiple access to a database when using an ORM

I'm trying to learn how to work with databases without just direct SQL, and stumbled upon the concept of ORM. There is problem I can find a solution for, and that is multiple access to the database.

For example, imagine there are two applications accessing the same data in the database. If I have loaded data into a programming language with ORM, and I do changes to it and commit the changes back to the database. While I'm manipulating the data in the programming language (and before I can commit the changes), someone else changes the data in the database. When I then commit my changes, wouldn't that be considered a ''dirty write'', and some data wold be lost?

Normally the DBMS would handle this with transactions, but that wouldn't apply here. How do I solve this? Not using an ORM if I need multiple access to the database? Instantly commit every change I'm doing in the ORM?

Aucun commentaire:

Enregistrer un commentaire