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
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "getting data using Hibernate" Watch "getting data using Hibernate" New topic

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

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
This is an excellent use cases here
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

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.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
krish bhadragiri

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;
Configuration config=new Configuration();
SessionFactory sessionFactory = config.buildSessionFactory();

Session session = sessionFactory.openSession();
Query q=session.createQuery("from Employee as emp");

catch(HibernateException ex)
I agree. Here's the link: http://aspose.com/file-tools
subject: getting data using Hibernate
It's not a secret anymore!