• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

List & hibenate

 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic