Forums Register Login

List & hibenate

+Pie Number of slices to send: Send
Hi,

I am new to hibenate. I want to extract list of countries from the country table(DB). I am using JSP & struts as front end.

Please guide the basic concept how to call country list in my application.

Thanks!!
+Pie Number of slices to send: Send
Well you would create a Country object, map it to the country table, then in a DAO layer object you would create either a Criteria, or Query, or SQLQuery object querying fo rthe data. Since it is a single table and you want all the records you can do one of the following two

Criteria criteria = new Criteria(Country.class);
List<Country> countries = criteria.list();


or


Query query = new Query("from Country");
List<Country> countries = query.list();


Both will run the same query to the database and return all the Countries.

Hope that helps

Mark
machines help you to do more, but experience less. Experience this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 641 times.
Similar Threads
Hibernate with Spring
Problem with Struts 2.0 check box
Generate Boiler Plate JDBC C-R-U-D Code
Problem in building hibernate SessionFactory
Regarding exam voucher
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:29:14.