This question is locked. New answers and comments are not allowed.
Hello i have a question about how open access works in the background. I have read all the documentation and the blogs but i just dont understand how Open Access Works exactly?
Well let me begin. Lets say I have a database with 2 tables customer and orders. Each costumer can have more orders (1:n).
Lets say i have mapped everything put some data inside the table thorugh the scope.
Now my question is what is happening exactly when i create a new scope in the memory. Writing getNewScope(). What happens. I understood it that in this moment in the memory (RAM) or 1st level cache an object container is created and only one object with the connection is made. When i make a query for example get me all customers who ordered more than once alle the customer objects with the orders are loaded into this objectcontainer?! Now every object has a unique id!is it the primary key or what is it?
Lets say this query gives me 10 results.
Now I do another query where i want to hav all customers who ordered mor than twice. Now this result lets say should give me 5 customers. But I have already thos 5 in the cache because of the first query. How does the OR Mapper know that he doesnt have to get those 5 customer object from the database. What is he comparing????
Second scenario i want to update a customer data. Well i have to open a transaction and change for example the address and then commit it. Well how does he know that something changed? I guess there is a flag but to what does the mapper compare the changed object or does he see taht something is changed and he sets the flag??
3 Scenario ist what happens if i work on changes for 20 minutes and in this time someone changed the same record in the database, but i am still working on the unchanged what is the OR Mapper doing in that situation when i commit????
I would really appreciate when someone explains it exactly to me because i am kind of confused about taht whats happening behind the scenes.
tomek
Well let me begin. Lets say I have a database with 2 tables customer and orders. Each costumer can have more orders (1:n).
Lets say i have mapped everything put some data inside the table thorugh the scope.
Now my question is what is happening exactly when i create a new scope in the memory. Writing getNewScope(). What happens. I understood it that in this moment in the memory (RAM) or 1st level cache an object container is created and only one object with the connection is made. When i make a query for example get me all customers who ordered more than once alle the customer objects with the orders are loaded into this objectcontainer?! Now every object has a unique id!is it the primary key or what is it?
Lets say this query gives me 10 results.
Now I do another query where i want to hav all customers who ordered mor than twice. Now this result lets say should give me 5 customers. But I have already thos 5 in the cache because of the first query. How does the OR Mapper know that he doesnt have to get those 5 customer object from the database. What is he comparing????
Second scenario i want to update a customer data. Well i have to open a transaction and change for example the address and then commit it. Well how does he know that something changed? I guess there is a flag but to what does the mapper compare the changed object or does he see taht something is changed and he sets the flag??
3 Scenario ist what happens if i work on changes for 20 minutes and in this time someone changed the same record in the database, but i am still working on the unchanged what is the OR Mapper doing in that situation when i commit????
I would really appreciate when someone explains it exactly to me because i am kind of confused about taht whats happening behind the scenes.
tomek