Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate not retrieving data from database

 
meghna koneru
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to java or hibernate...

Trying to get data from database...it does not pick up the data...

Authentication.java


Gatekeeper.java


Domain.java




Main.Class





It gives null values even though the User table has data
 
meghna koneru
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please someone respond....I wonder if it is the issue with the query "select distinct domainName from User"....Is this the way to write query in hibernate?
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to do two things.
1. Post if you are getting any exceptions.
2. Turn-on hibernate.show_sql=true in the configuration document and see what query it is running.
This will show you the SQL query which hibernate uses to fetch data.
 
Waswani Naresh
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mehgna,

Wrap your query execution code with in a transaction and it should work.

session.getTransaction().begin(); and session.getTransaction().commit();

Regards,
Naresh Waswani
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic