• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Steps to execute a query

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Am very new to spring.Can anybody tell me what are the steps to execute a query in spring

Thanks
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please specify more exactly - which query do you mean?
 
Maya More
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to execute a "select " query. Say fetch employee details from a employee table.
What are steps and calls to be made to execute using jdbcTemplate and hibernateTemplate.


Thanks
Meena
 
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

Maya More wrote:Hi,

I want to execute a "select " query. Say fetch employee details from a employee table.
What are steps and calls to be made to execute using jdbcTemplate and hibernateTemplate.


Thanks
Meena



Well, if I was using Hibernate, I don't use the template, I inject a SessionFactory into my Repository/DAO and write straight Hibernate code.
If I was using Jdbc, then I definitely would use the JdbcTemplate. That template has methods to run queries, where you pass in the SQL statement as a String and if you have parameters in the Query string, then pass those values in to the method of the template. If you want a domain object back, then you implement one of Spring's Callback interface like RowMapper or ResultSetExtractor.

For more information, I highly recommend reading the Spring documentation at www.springframework.org

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic