Castle ActiveProject retrieving stale data from FindAllByProperty
up vote
0
down vote
favorite
I have an older WinForms 4.x application which is using Castle.ActiveRecord 3.0.0 RC (which is I think the latest available version) on top of NHibernate 3.1.0.4000 (which is not the latest but it was current at that time).
I've noticed an odd data inconsistency behaviour inside one form. It creates a TransactionScope
for the lifetime of the form and doesn't commit it until the end. It fetches a list of objects and provides some editing UI for them. One of those is a checkbox for the IsPrimary
boolean property.
Only one object is supposed to have IsPrimary
== true, so when you toggle the checkbox it does:
var others = MyData.FindAllByProperty("IsPrimary", true)
.Where(x => x.Name != current.Name).ToList();
foreach (var data in others)
data.IsPrimary = false;
data.Save();
current.IsPrimary = true;
current.Save();
(Which probably could be done more efficiently, but ignore that for now. current
is the object which is having its checkbox ticked. And they do all have unique names.)
This works correctly most of the time, but if you open the window, tick the checkbox on some other item (so it does the above and correctly sets the previous one to false), and then without closing the window you try to tick the first item again, you end up with two objects set IsPrimary
.
The problem appears to be that FindAllByProperty
is returning the original object state outside of the form's transaction, ignoring any changes.
If I replace the call with this code:
var others = MyData.FindAll().Where(x => x.IsPrimary)
.Where(x => x.Name != current.Name).ToList();
Then it returns the correct result (including the changes made inside the form's transaction).
Is this a known bug? Is there a workaround other than using FindAll()
?
Edit: FWIW, using explicit criteria has the same result (it returns stale data, not the correct data):
var criteria = DetachedCriteria.For(typeof(MyData))
.SetResultTransformer(CriteriaSpecification.DistinctRootEntity)
.Add(Restrictions.Eq("IsPrimary", true))
.Add(Restrictions.Not(Restrictions.IdEq(current.Id)));
var others = MyData.FindAll(criteria);
// still stale
c# .net activerecord nhibernate castle-activerecord
add a comment |
up vote
0
down vote
favorite
I have an older WinForms 4.x application which is using Castle.ActiveRecord 3.0.0 RC (which is I think the latest available version) on top of NHibernate 3.1.0.4000 (which is not the latest but it was current at that time).
I've noticed an odd data inconsistency behaviour inside one form. It creates a TransactionScope
for the lifetime of the form and doesn't commit it until the end. It fetches a list of objects and provides some editing UI for them. One of those is a checkbox for the IsPrimary
boolean property.
Only one object is supposed to have IsPrimary
== true, so when you toggle the checkbox it does:
var others = MyData.FindAllByProperty("IsPrimary", true)
.Where(x => x.Name != current.Name).ToList();
foreach (var data in others)
data.IsPrimary = false;
data.Save();
current.IsPrimary = true;
current.Save();
(Which probably could be done more efficiently, but ignore that for now. current
is the object which is having its checkbox ticked. And they do all have unique names.)
This works correctly most of the time, but if you open the window, tick the checkbox on some other item (so it does the above and correctly sets the previous one to false), and then without closing the window you try to tick the first item again, you end up with two objects set IsPrimary
.
The problem appears to be that FindAllByProperty
is returning the original object state outside of the form's transaction, ignoring any changes.
If I replace the call with this code:
var others = MyData.FindAll().Where(x => x.IsPrimary)
.Where(x => x.Name != current.Name).ToList();
Then it returns the correct result (including the changes made inside the form's transaction).
Is this a known bug? Is there a workaround other than using FindAll()
?
Edit: FWIW, using explicit criteria has the same result (it returns stale data, not the correct data):
var criteria = DetachedCriteria.For(typeof(MyData))
.SetResultTransformer(CriteriaSpecification.DistinctRootEntity)
.Add(Restrictions.Eq("IsPrimary", true))
.Add(Restrictions.Not(Restrictions.IdEq(current.Id)));
var others = MyData.FindAll(criteria);
// still stale
c# .net activerecord nhibernate castle-activerecord
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an older WinForms 4.x application which is using Castle.ActiveRecord 3.0.0 RC (which is I think the latest available version) on top of NHibernate 3.1.0.4000 (which is not the latest but it was current at that time).
I've noticed an odd data inconsistency behaviour inside one form. It creates a TransactionScope
for the lifetime of the form and doesn't commit it until the end. It fetches a list of objects and provides some editing UI for them. One of those is a checkbox for the IsPrimary
boolean property.
Only one object is supposed to have IsPrimary
== true, so when you toggle the checkbox it does:
var others = MyData.FindAllByProperty("IsPrimary", true)
.Where(x => x.Name != current.Name).ToList();
foreach (var data in others)
data.IsPrimary = false;
data.Save();
current.IsPrimary = true;
current.Save();
(Which probably could be done more efficiently, but ignore that for now. current
is the object which is having its checkbox ticked. And they do all have unique names.)
This works correctly most of the time, but if you open the window, tick the checkbox on some other item (so it does the above and correctly sets the previous one to false), and then without closing the window you try to tick the first item again, you end up with two objects set IsPrimary
.
The problem appears to be that FindAllByProperty
is returning the original object state outside of the form's transaction, ignoring any changes.
If I replace the call with this code:
var others = MyData.FindAll().Where(x => x.IsPrimary)
.Where(x => x.Name != current.Name).ToList();
Then it returns the correct result (including the changes made inside the form's transaction).
Is this a known bug? Is there a workaround other than using FindAll()
?
Edit: FWIW, using explicit criteria has the same result (it returns stale data, not the correct data):
var criteria = DetachedCriteria.For(typeof(MyData))
.SetResultTransformer(CriteriaSpecification.DistinctRootEntity)
.Add(Restrictions.Eq("IsPrimary", true))
.Add(Restrictions.Not(Restrictions.IdEq(current.Id)));
var others = MyData.FindAll(criteria);
// still stale
c# .net activerecord nhibernate castle-activerecord
I have an older WinForms 4.x application which is using Castle.ActiveRecord 3.0.0 RC (which is I think the latest available version) on top of NHibernate 3.1.0.4000 (which is not the latest but it was current at that time).
I've noticed an odd data inconsistency behaviour inside one form. It creates a TransactionScope
for the lifetime of the form and doesn't commit it until the end. It fetches a list of objects and provides some editing UI for them. One of those is a checkbox for the IsPrimary
boolean property.
Only one object is supposed to have IsPrimary
== true, so when you toggle the checkbox it does:
var others = MyData.FindAllByProperty("IsPrimary", true)
.Where(x => x.Name != current.Name).ToList();
foreach (var data in others)
data.IsPrimary = false;
data.Save();
current.IsPrimary = true;
current.Save();
(Which probably could be done more efficiently, but ignore that for now. current
is the object which is having its checkbox ticked. And they do all have unique names.)
This works correctly most of the time, but if you open the window, tick the checkbox on some other item (so it does the above and correctly sets the previous one to false), and then without closing the window you try to tick the first item again, you end up with two objects set IsPrimary
.
The problem appears to be that FindAllByProperty
is returning the original object state outside of the form's transaction, ignoring any changes.
If I replace the call with this code:
var others = MyData.FindAll().Where(x => x.IsPrimary)
.Where(x => x.Name != current.Name).ToList();
Then it returns the correct result (including the changes made inside the form's transaction).
Is this a known bug? Is there a workaround other than using FindAll()
?
Edit: FWIW, using explicit criteria has the same result (it returns stale data, not the correct data):
var criteria = DetachedCriteria.For(typeof(MyData))
.SetResultTransformer(CriteriaSpecification.DistinctRootEntity)
.Add(Restrictions.Eq("IsPrimary", true))
.Add(Restrictions.Not(Restrictions.IdEq(current.Id)));
var others = MyData.FindAll(criteria);
// still stale
c# .net activerecord nhibernate castle-activerecord
c# .net activerecord nhibernate castle-activerecord
edited Nov 13 at 0:18
asked Nov 9 at 3:20
Miral
7,92823168
7,92823168
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
here are playing three things together:
- without commiting the data is not changed inside of the database.
- when possible nhibernate convertes restrictins into SQL and the database-server runs the checks. ONLY if possible.
- a session has a chace and if a record (primary) key is returned that is already in the chace it will ignore the record (values) and just reuse the object from the Cache.
This means Restrictions.Eq("IsPrimary", true) or Where(x => x.IsPrimary) will (I think) run in the database-server and can never see any data only changed in the application (aka. without commit, aka. transient data, aka. dirty data/objects). This means your list of objects you set IsPrimary=false is the worong list if more then one object in your application/session/chace has IsPrimary=true but in the database still IsPrimary=false !
You'd either have to do one of the following things, but all are bad in ther own way:
- load all objects without restriction
- or scann through the sesssion manually to find all transient/dirty objects
- or commit after every Change of IsPrimary
If possible I'd suggest you to switch from a boolean field in the table/class to a refercence field of the type of your data-object in a different table/class with only one entry and stor the primary object in that other table/class. It will automaticaly only allow one primary AND will cause a concurrency if two sessions/users try to create a primary at the same time (better then having two primaris :D ).
Perhaps your data-structure already has a kind of Father/supperior class to your data class and that one should know IT's Primary.
Greetings
Juy Juka
Why is the data not in the database, though? Granted there is still an open transaction, but the changes have been saved, and databases support multiple statements in the same transaction seeing each other's uncommitted changes.
– Miral
Nov 11 at 22:56
Hello Miral, NHibernate avoides to send any request to the database as much as possible! (I realy mean that exclamation mark. It realy, realy comunicates with the database as little as possible.) That means (next to other things) that neither an NHibernate-Transaction nor a Save do anything in the database, only the Dispose of an NHibernate-Transaction are sending anthing to the database (within a database-transaction). Greetings Juy Juka
– Juy Juka
Nov 12 at 7:00
So, what I'm hearing is that NHibernate is broken and we should avoid using it. :P (Also despite the :P I'm actually serious about that -- if it has been told about a pending modification but has refused to write it to the database and then returns an incorrect result from a subsequent read within the same transaction -- I can't think what else to call that than "fundamentally broken".)
– Miral
Nov 13 at 0:15
Hello, I'm using NHibernate and it is working fine. The trouble is to tell NHibernate exactly what you want. By default NHibernate tries to be as fast as possible, wich means - besides other things - that it will use dirty and transient objects to avoid comunication with the database. You would have to tell NHibernate 1) to commit or 2) write your changes (I don't know how to) or 3) work with the dirty/transient states (you cause them yourself, it's possible). Calling this borken is like caling a db-transaction brocken, because other users can't see uncommited stuff-it's by design.Greetings JJ
– Juy Juka
Nov 13 at 9:46
I make a change to some objects. I Save() those objects. I then ask for a list of the same objects which satisfy a particular property query. This is all within the same transaction. If this doesn't completely by itself use the current "dirty" object states within the same transaction, but instead goes and does a database query and then does not update this with its own internal "dirty" object states, then this is fundamentally broken.
– Miral
Nov 14 at 0:27
|
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
here are playing three things together:
- without commiting the data is not changed inside of the database.
- when possible nhibernate convertes restrictins into SQL and the database-server runs the checks. ONLY if possible.
- a session has a chace and if a record (primary) key is returned that is already in the chace it will ignore the record (values) and just reuse the object from the Cache.
This means Restrictions.Eq("IsPrimary", true) or Where(x => x.IsPrimary) will (I think) run in the database-server and can never see any data only changed in the application (aka. without commit, aka. transient data, aka. dirty data/objects). This means your list of objects you set IsPrimary=false is the worong list if more then one object in your application/session/chace has IsPrimary=true but in the database still IsPrimary=false !
You'd either have to do one of the following things, but all are bad in ther own way:
- load all objects without restriction
- or scann through the sesssion manually to find all transient/dirty objects
- or commit after every Change of IsPrimary
If possible I'd suggest you to switch from a boolean field in the table/class to a refercence field of the type of your data-object in a different table/class with only one entry and stor the primary object in that other table/class. It will automaticaly only allow one primary AND will cause a concurrency if two sessions/users try to create a primary at the same time (better then having two primaris :D ).
Perhaps your data-structure already has a kind of Father/supperior class to your data class and that one should know IT's Primary.
Greetings
Juy Juka
Why is the data not in the database, though? Granted there is still an open transaction, but the changes have been saved, and databases support multiple statements in the same transaction seeing each other's uncommitted changes.
– Miral
Nov 11 at 22:56
Hello Miral, NHibernate avoides to send any request to the database as much as possible! (I realy mean that exclamation mark. It realy, realy comunicates with the database as little as possible.) That means (next to other things) that neither an NHibernate-Transaction nor a Save do anything in the database, only the Dispose of an NHibernate-Transaction are sending anthing to the database (within a database-transaction). Greetings Juy Juka
– Juy Juka
Nov 12 at 7:00
So, what I'm hearing is that NHibernate is broken and we should avoid using it. :P (Also despite the :P I'm actually serious about that -- if it has been told about a pending modification but has refused to write it to the database and then returns an incorrect result from a subsequent read within the same transaction -- I can't think what else to call that than "fundamentally broken".)
– Miral
Nov 13 at 0:15
Hello, I'm using NHibernate and it is working fine. The trouble is to tell NHibernate exactly what you want. By default NHibernate tries to be as fast as possible, wich means - besides other things - that it will use dirty and transient objects to avoid comunication with the database. You would have to tell NHibernate 1) to commit or 2) write your changes (I don't know how to) or 3) work with the dirty/transient states (you cause them yourself, it's possible). Calling this borken is like caling a db-transaction brocken, because other users can't see uncommited stuff-it's by design.Greetings JJ
– Juy Juka
Nov 13 at 9:46
I make a change to some objects. I Save() those objects. I then ask for a list of the same objects which satisfy a particular property query. This is all within the same transaction. If this doesn't completely by itself use the current "dirty" object states within the same transaction, but instead goes and does a database query and then does not update this with its own internal "dirty" object states, then this is fundamentally broken.
– Miral
Nov 14 at 0:27
|
show 2 more comments
up vote
0
down vote
here are playing three things together:
- without commiting the data is not changed inside of the database.
- when possible nhibernate convertes restrictins into SQL and the database-server runs the checks. ONLY if possible.
- a session has a chace and if a record (primary) key is returned that is already in the chace it will ignore the record (values) and just reuse the object from the Cache.
This means Restrictions.Eq("IsPrimary", true) or Where(x => x.IsPrimary) will (I think) run in the database-server and can never see any data only changed in the application (aka. without commit, aka. transient data, aka. dirty data/objects). This means your list of objects you set IsPrimary=false is the worong list if more then one object in your application/session/chace has IsPrimary=true but in the database still IsPrimary=false !
You'd either have to do one of the following things, but all are bad in ther own way:
- load all objects without restriction
- or scann through the sesssion manually to find all transient/dirty objects
- or commit after every Change of IsPrimary
If possible I'd suggest you to switch from a boolean field in the table/class to a refercence field of the type of your data-object in a different table/class with only one entry and stor the primary object in that other table/class. It will automaticaly only allow one primary AND will cause a concurrency if two sessions/users try to create a primary at the same time (better then having two primaris :D ).
Perhaps your data-structure already has a kind of Father/supperior class to your data class and that one should know IT's Primary.
Greetings
Juy Juka
Why is the data not in the database, though? Granted there is still an open transaction, but the changes have been saved, and databases support multiple statements in the same transaction seeing each other's uncommitted changes.
– Miral
Nov 11 at 22:56
Hello Miral, NHibernate avoides to send any request to the database as much as possible! (I realy mean that exclamation mark. It realy, realy comunicates with the database as little as possible.) That means (next to other things) that neither an NHibernate-Transaction nor a Save do anything in the database, only the Dispose of an NHibernate-Transaction are sending anthing to the database (within a database-transaction). Greetings Juy Juka
– Juy Juka
Nov 12 at 7:00
So, what I'm hearing is that NHibernate is broken and we should avoid using it. :P (Also despite the :P I'm actually serious about that -- if it has been told about a pending modification but has refused to write it to the database and then returns an incorrect result from a subsequent read within the same transaction -- I can't think what else to call that than "fundamentally broken".)
– Miral
Nov 13 at 0:15
Hello, I'm using NHibernate and it is working fine. The trouble is to tell NHibernate exactly what you want. By default NHibernate tries to be as fast as possible, wich means - besides other things - that it will use dirty and transient objects to avoid comunication with the database. You would have to tell NHibernate 1) to commit or 2) write your changes (I don't know how to) or 3) work with the dirty/transient states (you cause them yourself, it's possible). Calling this borken is like caling a db-transaction brocken, because other users can't see uncommited stuff-it's by design.Greetings JJ
– Juy Juka
Nov 13 at 9:46
I make a change to some objects. I Save() those objects. I then ask for a list of the same objects which satisfy a particular property query. This is all within the same transaction. If this doesn't completely by itself use the current "dirty" object states within the same transaction, but instead goes and does a database query and then does not update this with its own internal "dirty" object states, then this is fundamentally broken.
– Miral
Nov 14 at 0:27
|
show 2 more comments
up vote
0
down vote
up vote
0
down vote
here are playing three things together:
- without commiting the data is not changed inside of the database.
- when possible nhibernate convertes restrictins into SQL and the database-server runs the checks. ONLY if possible.
- a session has a chace and if a record (primary) key is returned that is already in the chace it will ignore the record (values) and just reuse the object from the Cache.
This means Restrictions.Eq("IsPrimary", true) or Where(x => x.IsPrimary) will (I think) run in the database-server and can never see any data only changed in the application (aka. without commit, aka. transient data, aka. dirty data/objects). This means your list of objects you set IsPrimary=false is the worong list if more then one object in your application/session/chace has IsPrimary=true but in the database still IsPrimary=false !
You'd either have to do one of the following things, but all are bad in ther own way:
- load all objects without restriction
- or scann through the sesssion manually to find all transient/dirty objects
- or commit after every Change of IsPrimary
If possible I'd suggest you to switch from a boolean field in the table/class to a refercence field of the type of your data-object in a different table/class with only one entry and stor the primary object in that other table/class. It will automaticaly only allow one primary AND will cause a concurrency if two sessions/users try to create a primary at the same time (better then having two primaris :D ).
Perhaps your data-structure already has a kind of Father/supperior class to your data class and that one should know IT's Primary.
Greetings
Juy Juka
here are playing three things together:
- without commiting the data is not changed inside of the database.
- when possible nhibernate convertes restrictins into SQL and the database-server runs the checks. ONLY if possible.
- a session has a chace and if a record (primary) key is returned that is already in the chace it will ignore the record (values) and just reuse the object from the Cache.
This means Restrictions.Eq("IsPrimary", true) or Where(x => x.IsPrimary) will (I think) run in the database-server and can never see any data only changed in the application (aka. without commit, aka. transient data, aka. dirty data/objects). This means your list of objects you set IsPrimary=false is the worong list if more then one object in your application/session/chace has IsPrimary=true but in the database still IsPrimary=false !
You'd either have to do one of the following things, but all are bad in ther own way:
- load all objects without restriction
- or scann through the sesssion manually to find all transient/dirty objects
- or commit after every Change of IsPrimary
If possible I'd suggest you to switch from a boolean field in the table/class to a refercence field of the type of your data-object in a different table/class with only one entry and stor the primary object in that other table/class. It will automaticaly only allow one primary AND will cause a concurrency if two sessions/users try to create a primary at the same time (better then having two primaris :D ).
Perhaps your data-structure already has a kind of Father/supperior class to your data class and that one should know IT's Primary.
Greetings
Juy Juka
answered Nov 9 at 21:25
Juy Juka
1317
1317
Why is the data not in the database, though? Granted there is still an open transaction, but the changes have been saved, and databases support multiple statements in the same transaction seeing each other's uncommitted changes.
– Miral
Nov 11 at 22:56
Hello Miral, NHibernate avoides to send any request to the database as much as possible! (I realy mean that exclamation mark. It realy, realy comunicates with the database as little as possible.) That means (next to other things) that neither an NHibernate-Transaction nor a Save do anything in the database, only the Dispose of an NHibernate-Transaction are sending anthing to the database (within a database-transaction). Greetings Juy Juka
– Juy Juka
Nov 12 at 7:00
So, what I'm hearing is that NHibernate is broken and we should avoid using it. :P (Also despite the :P I'm actually serious about that -- if it has been told about a pending modification but has refused to write it to the database and then returns an incorrect result from a subsequent read within the same transaction -- I can't think what else to call that than "fundamentally broken".)
– Miral
Nov 13 at 0:15
Hello, I'm using NHibernate and it is working fine. The trouble is to tell NHibernate exactly what you want. By default NHibernate tries to be as fast as possible, wich means - besides other things - that it will use dirty and transient objects to avoid comunication with the database. You would have to tell NHibernate 1) to commit or 2) write your changes (I don't know how to) or 3) work with the dirty/transient states (you cause them yourself, it's possible). Calling this borken is like caling a db-transaction brocken, because other users can't see uncommited stuff-it's by design.Greetings JJ
– Juy Juka
Nov 13 at 9:46
I make a change to some objects. I Save() those objects. I then ask for a list of the same objects which satisfy a particular property query. This is all within the same transaction. If this doesn't completely by itself use the current "dirty" object states within the same transaction, but instead goes and does a database query and then does not update this with its own internal "dirty" object states, then this is fundamentally broken.
– Miral
Nov 14 at 0:27
|
show 2 more comments
Why is the data not in the database, though? Granted there is still an open transaction, but the changes have been saved, and databases support multiple statements in the same transaction seeing each other's uncommitted changes.
– Miral
Nov 11 at 22:56
Hello Miral, NHibernate avoides to send any request to the database as much as possible! (I realy mean that exclamation mark. It realy, realy comunicates with the database as little as possible.) That means (next to other things) that neither an NHibernate-Transaction nor a Save do anything in the database, only the Dispose of an NHibernate-Transaction are sending anthing to the database (within a database-transaction). Greetings Juy Juka
– Juy Juka
Nov 12 at 7:00
So, what I'm hearing is that NHibernate is broken and we should avoid using it. :P (Also despite the :P I'm actually serious about that -- if it has been told about a pending modification but has refused to write it to the database and then returns an incorrect result from a subsequent read within the same transaction -- I can't think what else to call that than "fundamentally broken".)
– Miral
Nov 13 at 0:15
Hello, I'm using NHibernate and it is working fine. The trouble is to tell NHibernate exactly what you want. By default NHibernate tries to be as fast as possible, wich means - besides other things - that it will use dirty and transient objects to avoid comunication with the database. You would have to tell NHibernate 1) to commit or 2) write your changes (I don't know how to) or 3) work with the dirty/transient states (you cause them yourself, it's possible). Calling this borken is like caling a db-transaction brocken, because other users can't see uncommited stuff-it's by design.Greetings JJ
– Juy Juka
Nov 13 at 9:46
I make a change to some objects. I Save() those objects. I then ask for a list of the same objects which satisfy a particular property query. This is all within the same transaction. If this doesn't completely by itself use the current "dirty" object states within the same transaction, but instead goes and does a database query and then does not update this with its own internal "dirty" object states, then this is fundamentally broken.
– Miral
Nov 14 at 0:27
Why is the data not in the database, though? Granted there is still an open transaction, but the changes have been saved, and databases support multiple statements in the same transaction seeing each other's uncommitted changes.
– Miral
Nov 11 at 22:56
Why is the data not in the database, though? Granted there is still an open transaction, but the changes have been saved, and databases support multiple statements in the same transaction seeing each other's uncommitted changes.
– Miral
Nov 11 at 22:56
Hello Miral, NHibernate avoides to send any request to the database as much as possible! (I realy mean that exclamation mark. It realy, realy comunicates with the database as little as possible.) That means (next to other things) that neither an NHibernate-Transaction nor a Save do anything in the database, only the Dispose of an NHibernate-Transaction are sending anthing to the database (within a database-transaction). Greetings Juy Juka
– Juy Juka
Nov 12 at 7:00
Hello Miral, NHibernate avoides to send any request to the database as much as possible! (I realy mean that exclamation mark. It realy, realy comunicates with the database as little as possible.) That means (next to other things) that neither an NHibernate-Transaction nor a Save do anything in the database, only the Dispose of an NHibernate-Transaction are sending anthing to the database (within a database-transaction). Greetings Juy Juka
– Juy Juka
Nov 12 at 7:00
So, what I'm hearing is that NHibernate is broken and we should avoid using it. :P (Also despite the :P I'm actually serious about that -- if it has been told about a pending modification but has refused to write it to the database and then returns an incorrect result from a subsequent read within the same transaction -- I can't think what else to call that than "fundamentally broken".)
– Miral
Nov 13 at 0:15
So, what I'm hearing is that NHibernate is broken and we should avoid using it. :P (Also despite the :P I'm actually serious about that -- if it has been told about a pending modification but has refused to write it to the database and then returns an incorrect result from a subsequent read within the same transaction -- I can't think what else to call that than "fundamentally broken".)
– Miral
Nov 13 at 0:15
Hello, I'm using NHibernate and it is working fine. The trouble is to tell NHibernate exactly what you want. By default NHibernate tries to be as fast as possible, wich means - besides other things - that it will use dirty and transient objects to avoid comunication with the database. You would have to tell NHibernate 1) to commit or 2) write your changes (I don't know how to) or 3) work with the dirty/transient states (you cause them yourself, it's possible). Calling this borken is like caling a db-transaction brocken, because other users can't see uncommited stuff-it's by design.Greetings JJ
– Juy Juka
Nov 13 at 9:46
Hello, I'm using NHibernate and it is working fine. The trouble is to tell NHibernate exactly what you want. By default NHibernate tries to be as fast as possible, wich means - besides other things - that it will use dirty and transient objects to avoid comunication with the database. You would have to tell NHibernate 1) to commit or 2) write your changes (I don't know how to) or 3) work with the dirty/transient states (you cause them yourself, it's possible). Calling this borken is like caling a db-transaction brocken, because other users can't see uncommited stuff-it's by design.Greetings JJ
– Juy Juka
Nov 13 at 9:46
I make a change to some objects. I Save() those objects. I then ask for a list of the same objects which satisfy a particular property query. This is all within the same transaction. If this doesn't completely by itself use the current "dirty" object states within the same transaction, but instead goes and does a database query and then does not update this with its own internal "dirty" object states, then this is fundamentally broken.
– Miral
Nov 14 at 0:27
I make a change to some objects. I Save() those objects. I then ask for a list of the same objects which satisfy a particular property query. This is all within the same transaction. If this doesn't completely by itself use the current "dirty" object states within the same transaction, but instead goes and does a database query and then does not update this with its own internal "dirty" object states, then this is fundamentally broken.
– Miral
Nov 14 at 0:27
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53219379%2fcastle-activeproject-retrieving-stale-data-from-findallbyproperty%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown