aspose file tools
The moose likes Object Relational Mapping and the fly likes Hibernate Result Set Different then SQL Result Set Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Hibernate Result Set Different then SQL Result Set" Watch "Hibernate Result Set Different then SQL Result Set" New topic
Author

Hibernate Result Set Different then SQL Result Set

Ankit V Agrawal
Greenhorn

Joined: Jan 27, 2012
Posts: 9
Hi,

I'm running a query to fetch some 100 records from the database. The Database is SQL Server 2008.
When I'm running the query from the MS SQL Management Studio it is returning the correct result set.
But when I'm running it thru hibernate the result set is different.

I have tried to print the query and the query is being printed exactly as what I want it to be. Still the result set is different when I iterate thru the list and print it.

Also I have checked that the my code is connecting to the correct data base.

Any idea if hibernate does some kind of caching issues ? Has anybody faced this kind of problem before ?
Any help would be appreciated.

Regards,
Ank


SCJP 5.0, SCWCD 5.0
Ankit V Agrawal
Greenhorn

Joined: Jan 27, 2012
Posts: 9
I tried to test the query thru JDBC and that is also returning the right result. So it has got to do something with hibernate.

2 Records fetched
Transaction ID From Hibernate :: 3062
Transaction ID From Hibernate :: 3062

Transaction ID From JDBC :: 3062
Transaction ID From JDBC :: 3063

Any ideas what is going wrong ?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3563

But when I'm running it thru hibernate the result set is different.

In what way(s) this is different form the normal behavior?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Ankit V Agrawal
Greenhorn

Joined: Jan 27, 2012
Posts: 9
hibernate was returning the same object 2 times. I found the error, the unique key was wrongly defined!
 
 
subject: Hibernate Result Set Different then SQL Result Set
 
Threads others viewed
How do I implement time?
Strange behavior with Hibernate
getting the resultset of a stored procedure?
Retrieving meta data / column name from a native sql query / store procedure
Sorting problem with HibernateSqlQuery with Websphere
MyEclipse, The Clear Choice