Hi,
We are experiencing problems in Hibernate with the following exception appearing in our unit test logs:
Quote:
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: 33, of class: foo
However this row definitely exists in the database. We have looked into the problem in depth and have traced it to a previous call in the unit tests to the following line in net.sf.hibernate.loader.Loader.doQuery
Quote:
if (owners!=null) registerNonExists(keys, owners, persisters, session);
It seems that this row is being erroneously added to the nonExists collection and is therefore causing the later doLoad call in SessionImpl to bomb out with the ObjectNotFoundException exception.
We have now commented out this line of code and the problem is fixed. This leads us to some questions that we hope you can answer,
1) This code seems designed to optimize performance in some way, why is the caching of rows that don't exist necessary?
2) How is this code inferring whether a particular row exists without selecting it?
3) Why would hibernate try to load a non-existing row in the first place (assuming foreign key constraints are implemented in the DB)
4) In what ways are we affecting the performance of Hibernate by commenting out this line?
Many Thanks,
Adam.[code][/code]