ssh-配置事务管理器

applicationContext.xml:



	
	
	 	
	

	
		
	

	 
	 


	
		
		
		
		
				
		
		
		
		
		
		
		
	
	
	
		
			
			
			
			
		
			
				com/domain/Employee.hbm.xml
				com/domain/Department.hbm.xml
				
				
		
		
			
					hibernate.dialect=org.hibernate.dialect.SQLServerDialect
					hibernate.hbm2ddl.auto=update
			
		
	
	
	
	
  		
	
	
	
	
	
	
		
	
	
		
		
	
	
	
	
	
		
	
	
		
		
	
	
		
	
	
		
	


BasicService:
package com.basic;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.transaction.annotation.Transactional;

//事务注解,spring统一管理事务的提交
@Transactional
public abstract class BasicService implements BasicServiceInter {
	
	private SessionFactory sessionFactory;
	
	@Override
	public Object findById(Class clazz, Serializable id) {
		// TODO Auto-generated method stub
		return sessionFactory.getCurrentSession().get(clazz, id);
		
	}

	@Override
	public List exrcuteQuery(String hql, Object[] parameter) {
		// TODO Auto-generated method stub
		System.out.println("得到hql为:"+hql);
		
		Session session=sessionFactory.getCurrentSession();
		Query query=session.createQuery(hql);
		
		if(parameter!=null&¶meter.length>0){
			for(int a=0;a0){
			for(int a=0;a0){
			for(int a=0;a


你可能感兴趣的:(ssh)