Actually I fetching recrods from a View. I cannot use unique key here. Is this problem relates something with cache.
No, this is not strictly a caching problem. ORM tools only work with relational data. A table or view without a primary key is not relational, so an ORM tool wont work with it. What is most likely happening is you are using a non-unique value for your identifier so Hibernate loads the first object with an id of 3 and any subsequent requests for an object of this type with this id gets the one Hibernate has already loaded. Fix this by giving your view a surrogate key.
Dhiraj Srivastava
Ranch Hand
Joined: Aug 29, 2001
Posts: 49
posted
0
Hi...
Thanks.. Its working..
Regards,
Dhiraj..
Dhiraj Srivastava
Ranch Hand
Joined: Aug 29, 2001
Posts: 49
posted
0
Hi,
Still I have major issue.
Consider Following Recrods
Id Amount 1 400 2 500 3 500 3 250 3 -
As In this table I don't have any unique combination. Even in composite key. Now I want all the records as it is.
Now if I put Id Column as primary key it will give:
Id Amount 1 400 2 500 3 500 3 500 3 500
500 will repeat in all the Id 3 records. And If put both of these coloumns in the <composite-id> tag I get the following records.
Id Amount 1 400 2 500 3 500 3 250
Now you can see last record is not coming. Becase Amount Value was null.
All I want the exact records in my Hibernate Query. As I get from SQL
You can't use a composite key with a null value; keys can't contain nulls. If you want Hibernate to work with your view, give your view a surrogate key.