Five ‘s Weblog

October 30, 2007

Is there any repeat?

Filed under: Five's thought,Spring — by powerdream5 @ 9:41 pm
Tags: ,

       As we all know, Spring DAO is based on template method pattern. The reason why Spring DAO adopts template method pattern is that there are some setted processes before and after accessing the database, such as start and commit the transaction, open and close the database connection. Therefore, when we use Spring DAO template, for example, HibernateTemplate and JdoTemplate, we don’t need to write code for transactions by ourselves, since the DAO template will does that job for us.

       However, I has been thinking about a question , and I still not find the answer to it. Spring framework supports declaration transaction. In fact, in many projects, we use DAO template to access the database, at the same time, we also configure transaciton in spring configuration files. Therefore, is it necessary to declare transaions in spring configuration files when we already take the advantage of DAO template, which already helps us handle transactions? is it redundant for us to do that?

       In order to find the answer, I have refered to some materies. There is an explansion in spring document. It is that “even if HibernateTransactionManager is used for transaction demarcation in higher-level services, all those services above the data access layer don’t need to be Hibernate-aware. Setting such a special PlatformTransactionManager is a configuration issue: For example, switching to JTA is just a matter of Spring configuration (use JtaTransactionManager instead) that does not affect application code.”

      What is your opinion about this explanation. To be honest, It doesn’t make sense to me and it still not help me answer this question. I am sorry for my slow response. I hope you can help me solve this question! Thanks a lot!

10_30_1_2007.jpg

Advertisements

3 Comments »

  1. ギャルソン 財布 レディース givenchy 財布 http://xinkaijiwy.breitlingcarrier2013.com/

    Comment by givenchy 財布 — December 1, 2013 @ 1:06 pm |Reply

  2. Hi, Neat post. There is a problem with your website in web explorer, could check this¡K IE
    nonetheless is the market chief and a large component of other people
    will miss your wonderful writing due to this problem.

    Comment by Louis Lundborg — April 1, 2014 @ 7:18 am |Reply

  3. I am sure this paragraph has touched all the internet viewers, its really really good article on
    building up new blog.

    Comment by essential oil — April 29, 2014 @ 4:36 am |Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: