Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Steps to execute a query

 
Maya More
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Boris Romashov
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic