Results 1 to 2 of 2

Thread: Why is setDatSource() method in JdbcDaoSupport final?

  1. #1
    Join Date
    Jun 2011
    Posts
    1

    Smile Why is setDatSource() method in JdbcDaoSupport final?

    Shouldn't this method have been made just public and not final as well? If not final I could do something like this on my DOAs which extends JdbcDoaSupport:
    public class MyDao extends JdbcDaoSupport implements MyDoaIntF{

    @Autowired
    @Qualifier("coolDataSource")
    @Override
    public void setDataSource(DataSource dataSource){
    super.setDataSource(dataSource);
    }
    }

    now I have to do something like this:
    @Autowired
    @Qualifier("coolDataSource")
    public void setMyDataSource(DataSource dataSource){
    super.setDataSource(dataSource);
    }
    which its not entirely cool.
    p.s. I may be a bit pedantic here....

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    JdbcDaoSupport doesn't give you much added benefit, so you can either simply create a new JdbcTemplate yourself or inject a JdbcTemplate (saves you extending the spring classes). Next to that you could (and IMHO that is the best solution) create a constructor which takes a DataSource you can do anything you like with the @Autowired annotation. (IMHO the setDataSource method shouldn't have been there in the first place, because a Jdbc based dao without a datasource is pretty useless).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •