I am following the PDF tutorial for Spring MVC that came along with Spring 2.5 bundle. This may seem to be a naive question, But I have following bean declaration in my applicationContext.xml
What I expected by this declaration is that, (in crudest terms) the class JdbcProductDao should contain a variable of type dataSourcewhich will have methods setDataSource() and getDataSource().
But class JdbcProductDao is as shown below,
SimpleJdbcDaoSupport doesn't have a field of type DataSource. So how come the a property of "dataSource" is set for JdbcProductDao
[Edited to add 1 more question]
From what I gathered about Spring is that every Class in Spring is a bean.So setters and getters are must for every class.So, whay doesn't JdbcProductDao doesn't have any?
Thanks, [ October 04, 2008: Message edited by: K Aditi ]
Look in the SimpleJdbcDaoSupport class that you are extending.
Now, I will point out this, I would not extend that class. At the point where you go "extends SimpleJdbcDaoSupport" you are now tightly coupled with a Spring class.
The best way to do JDBC Repositories is to inject a SimpleJdbcTemplate into your Repository, and use the template. In your xml you will declare a SimpleJdbcTemplate to inject into your JdbcProductDao, which would require you to create a private instance variable to hold it, and write a setter method to inject it.