Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Select query not working properly  RSS feed

 
Abhinav Sahai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am doing simple select query on a table, which has three separate records in database.
In the output, I see only one record, 3 times. It seems the rest of the objects are getting overwritten by the first object.

Code:

HBM file:


Please help!

[ August 11, 2008: Message edited by: Abhinav Sahai ]

[ August 11, 2008: Message edited by: Abhinav Sahai ]
[ August 11, 2008: Message edited by: Paul Sturrock ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, you are querying for objects by primary key and expect three results? This sounds like imageID is not actually a primary key. Hibernate identifies object based on primary key (since that is the same logic the database uses). So if it finds one object with a specific id it assumes that is the only object of that type with that id.
 
Kuladip Yadav
Ranch Hand
Posts: 162
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your HBM file says that imageID is primary key.

So resultant ifnList doesn't contains more than one record.

In the output, I see only one record, 3 times.


Then how do you see one record 3 times ?
May be you want to achieve some thing else.
 
Abhinav Sahai
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Paul and Kuldeep.
It was spot on.

ImageID was not the primary key, instead it was image_file_id

Thanks a lot again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!