wood burning stoves 2.0*
The moose likes Spring and the fly likes Steps to execute a query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Steps to execute a query" Watch "Steps to execute a query" New topic
Author

Steps to execute a query

Maya More
Greenhorn

Joined: Jun 28, 2011
Posts: 2
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

Joined: Feb 23, 2009
Posts: 38
Please specify more exactly - which query do you mean?
Maya More
Greenhorn

Joined: Jun 28, 2011
Posts: 2
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Steps to execute a query
 
Similar Threads
How to retrive array from database
PreparedStatement
how to execute a jsp page
execute method in SQl
pre-compile and prepared statement