• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

List & hibenate

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic