Results 1 to 3 of 3

Thread: Why getJdbcTemplate in JdbcDaoSupport not protected

  1. #1
    Join Date
    Dec 2008
    Posts
    1

    Default Why getJdbcTemplate in JdbcDaoSupport not protected

    Hi,
    is there a reason why the method getJdbcTemplate in the class JdbcDaoSupport is made public and not protected? I thought the purpose of the method getJdbcTemplate is to provide a JdbcTemplate to DAO subclasses. For that purpose protected would be sufficient. But by making this method public all clients using the DAO subclass can access the JdbcTemplate by calling getJdbcTemplate and make database calls bypassing the DAO layer.
    So would`t it be a better design to make the method protected in JdbcDaoSupport to prevent such usages?

    Thanx for your replies.

  2. #2

    Default

    Yep you're right (I try to thing about not extending but aggregating JdbcDaoSupport but this is rather dummy example).

    I think that the main reason is to follow JavaBean public getter/setter convention.

  3. #3
    Join Date
    Dec 2007
    Posts
    130

    Default

    Probably for test purposes. That way, you may check externally that jdbcTemplate was correctly injected, and even meake a few tests to connection

Posting Permissions

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