Spring4学习(五)声明式事务配置一

阅读更多

       基于Spring的DataSourceTransactionMananger类事务管理器配置声明式事务



        
        
	
   
    
   

	
        
        
        
        
    

    
    
    
    
    
    	
	
    
    
     
        
        
            
            
            
            
            
        
    
    
    
    
    
    
        
        
    
    

   service层java interface

package org.lian.service;

import org.lian.domain.Contacts;

public interface ContactsManagerService {

	public Contacts getContacts(Contacts contacts);

	public void addContacts(Contacts contacts);

	public void editContacts(Contacts contacts);
}

 实现类

@Service("contactsManagerService")
public class ContactsManagerServiceImpl implements ContactsManagerService {

	@Autowired
	@Qualifier("contactsDao")
	private ContactsDao contactsDao;

	public ContactsDao getContactsDao() {
		return contactsDao;
	}

	public void setContactsDao(ContactsDao contactsDao) {
		this.contactsDao = contactsDao;
	}

	@Autowired
	@Qualifier("musicDao")
	private MusicDao musicDao;

	public MusicDao getMusicDao() {
		return musicDao;
	}

	public void setMusicDao(MusicDao musicDao) {
		this.musicDao = musicDao;
	}

	@Override
	public Contacts getContacts(Contacts contacts) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void addContacts(Contacts contacts) {
		Music music = new Music();
		music.setId(IdGenerator.getInstance().getUUID());
		music.setName("唇语");
		music.setSinger("任然");
		music.setAlbum("从小到大");
		music.setAuthor("耕耕");
		music.setComposer("Xun");
		music.setStyle("流行");
		music.setDuration("04:48");
		// 添加一个music对象
		musicDao.add(music);
		contactsDao.insertContacts(contacts);
		// 事务
	}

	@Override
	public void editContacts(Contacts contacts) {
		// TODO Auto-generated method stub

	}

}

 

  • aopalliance.jar (4.4 KB)
  • 下载次数: 1
  • aspectjweaver-1.6.9.jar (1.6 MB)
  • 下载次数: 0

你可能感兴趣的:(Spring,声明式事务)