wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes getting data using Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "getting data using Hibernate" Watch "getting data using Hibernate" New topic
Author

getting data using Hibernate

Ingoba Ningthoujam
Ranch Hand

Joined: Dec 04, 2006
Posts: 90
Hi I am new in Hibernate,Pliz somebody tell me to how to select data from table using Hibernate.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The documentation covers this. What have you tried? What is confusing you?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rashid Darvesh
Ranch Hand

Joined: Feb 13, 2004
Posts: 189
HI
This is an excellent use cases here
http://www.makemyinfo.com/Tutorial.do?action=getTutorial&tutId=T0005.jsp
Rashid
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Be a little careful with the link that Rashid posted, while most of it is a good example to see, there are a couple bad practices in there, including probably wanting to use try catches around your unit of works.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
krish bhadragiri
Greenhorn

Joined: Apr 17, 2007
Posts: 13
e.g (say you have a employee table in a database.and you have mapped that employee table with Employee.hbm.xml in hibernate to the Employee.java persistent class.then use the following code to select details from table.
note:u have to keep the Employee.hbm.xml in the classpath of persistent class.and give that description of mapping file .hibernate.cfg.xml)

List<Employee> employees=null;
try
{
Configuration config=new Configuration();
config=config.configure();
SessionFactory sessionFactory = config.buildSessionFactory();

Session session = sessionFactory.openSession();
Query q=session.createQuery("from Employee as emp");
System.out.println(q.getQueryString());
employees=q.list();



}
catch(HibernateException ex)
{
ex.printStackTrace();
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting data using Hibernate
 
Similar Threads
EHCache not working
Load Data into database using Hibernate
Help in Data exports
Inserting a blob using hibernate
handling null's declaratively