afunms

          My Software,My Dream—Forge a more perfect NMS product.

          perfect DAO solution

          DAO design was revised repeatedly recent days,I am glad of  getting a perfect DAO solution
          finally.
            The sticking point in DAO design is where a DB connection is opened and when
          to close it. Sometimes,one action executes only one DAO method,the connection
          should be closed immediately follow the method. Sometimes, However, one action
          may contain many DAOs or a series of methods in a DAO, (in other words, called transaction).
          A same connection is used in DAOs,so closing connection after method execution is incorrect.
            Therefore,I wrote two DAO's constructors for above two scenarios.For the first scenario,
          opening a connection inside DAO,and close it at once after a method is invoked.For the second
          scenario,a connection is created outside DAO, when instantiating a new DAO class,the connection
          is passed from outside.We cope with this case (a transaction) in a service,the service invokes more
          than one DAOs.DB connection is opened when service starting,and closed at the end of service.

          posted on 2008-01-09 10:21 afunms 閱讀(164) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           

          My Links

          News

          留言簿(18)

          隨筆檔案

          相冊

          搜索

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 盈江县| 涟水县| 乌什县| 宿州市| 呼玛县| 汾西县| 乡城县| 九江市| 天柱县| 星座| 修武县| 成都市| 仲巴县| 绍兴县| 衡东县| 雅江县| 台北县| 长治市| 包头市| 双城市| 清河县| 平利县| 陆川县| 开封市| 漳浦县| 赞皇县| 卓尼县| 定日县| 永康市| 邢台市| 天峻县| 贵港市| 扎兰屯市| 汉源县| 迁安市| 淳安县| 定陶县| 乡城县| 周至县| 金塔县| 清水河县|