Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No data

 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am a newbie to hibernate. I created a simple table as below.

TEST
Tid -- PK
ReportId
IndexId

I am able to insert data successfully. When I retrieve the same record. It does not return anything. Please look at the code below.



When I look at the List, no data is returned. Where am I wrong? Please advise on the same.

The hbm.xml file is as below


Thanks,
Ananth Ram
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After you inserted your data did you commit the transaction? Are there any test objects that exists in the database with the report id you are using?
 
Charan kumar sarvepalli
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have written SQL query (not HQL) so try to get data using session.createSQLQuery(sql);
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Charan kumar sarvepalli wrote:you have written SQL query (not HQL) so try to get data using session.createSQLQuery(sql);


The above statement is valid in both languages.
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, the inserted data exists in the database.

Thanks,
Ananth Ram
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then it should work. Any reason you are not logging any exception that may be thrown?
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all,

it works...

Thanks,
Ananth Ram
 
Charan kumar sarvepalli
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ananth what makes solves your problem. can you post.
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Charan,

First the createSQLQuery in stead of SQLQuery. Thanks for pointing out.
then the next step is casting the object[] from the result List.

Let me know if you need more info.

Thanks,
Ananth Ram
 
Charan kumar sarvepalli
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just to know that solved your problem or you found any other solution.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic