The Spring Stack 2008 – Part1
Spring 2.0 introduced support for various annotations for configuration purposes, such as:
- @Transactional – The @Transactional annotation may be placed before an interface definition, a method on an interface, a class definition, or a public method on a class. However, please note that the mere presence of the @Transactional annotation is not enough to actually turn on the transactional behavior.
- @Required – used to mark a property as being ‘required-to-be-set’ (i.e. an annotated (setter) method of a class must be configured to be dependency injected with a value)
- @PersistenceContext – annotated on EntityManager instances are not thread safe
- @PersistenceUnit – annotated on EntityManagerFactory instances are thread-safe
Thus, to use annotations for the transactions for my purposes, I do the following:
- Put an tag tx:annotation-driven in the config file (i.e applicationContext.xml)
- Put @Transactional annotation in the services class implementation that contains operations on the entity manager
Spring 2.5 introduces support for a complete set of configuration annotations:
- @Autowired in combination with support for the JSR-250 annotations @Resource
- @PostConstruct
- @PreDestroy
Advertisements
1 Comment »
Leave a Reply
Advertisements
[…] , Testing , Spring 2.0 , IBatis Spring , Web […]
Pingback by Core Spring via Interface21~SpringSource~VMWare « TechnoBuzz | June 29, 2010 |