// Path: architecture-orm/src/main/java/com/ea/core/orm/handle/AbstractORMHandle.java
// public abstract class AbstractORMHandle implements ORMHandle, ApplicationContextAware {
// 	protected ApplicationContext context = null;
// 	
//     @Autowired
//     private SqlSessionTemplate mybatisSessionTemplate;
//     @Autowired
//     private SessionFactory hibernateSessionFactory;
//     
// 	private String level;
// 	private ORMHandle nextHandle;
// 	
// 	public AbstractORMHandle(String level){
// 		this.level = level;
// 	}
// 	
// 	/**
// 	 * 符合当前Level，则执行DB操作，否则交由下个Handle去执行
// 	 */
// 	public final Object handle(String level, ORMParamsDTO dto) throws Exception {
// 		if(this.level.equals(level)){
// 			return this.execute(dto);
// 		} else {
// 			this.setNextHandle();
// 			if(this.nextHandle != null){
// 				return this.nextHandle.handle(level, dto);
// 			} else {
// 				throw new Exception("必须设置ORMHandle处理当前请求");
// 			}
// 		}
// 	}
// 	
// 	/**
// 	 * 执行DB操作
// 	 * @param dto
// 	 * @return
// 	 * @throws Exception
// 	 */
// 	protected abstract Object execute(ORMParamsDTO dto) throws Exception;
// 	
// 	/**
// 	 * 设置下个Handle，子类设置，如果是最后一个Handle，不设置
// 	 */
// 	public abstract void setNextHandle();
// 
// 	protected SqlSessionTemplate getMybatisSessionTemplate() {
// 		return mybatisSessionTemplate;
// 	}
// 
// 	protected SessionFactory getHibernateSessionFactory() {
// 		return hibernateSessionFactory;
// 	}
// 	
// 	public void setApplicationContext(ApplicationContext applicationContext) {
// 		// TODO Auto-generated method stub
// 		context = applicationContext;
// 	}
// 	
// 	protected void setNextHandle(ORMHandle nextHandle){
// 		this.nextHandle = nextHandle;
// 	}
// 
// }
// 
// Path: architecture-orm/src/main/java/com/ea/core/orm/handle/ORMHandle.java
// public interface ORMHandle {
// 
// 	public Object handle(String level, ORMParamsDTO dto) throws Exception;
// }
// 
// Path: architecture-orm/src/main/java/com/ea/core/orm/handle/dto/ORMParamsDTO.java
// public class ORMParamsDTO implements Serializable{
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 1L;
// 	
// 	private Object param;
// 	private String sqlid;
// 	
// 	public Object getParam() {
// 		return param;
// 	}
// 	public void setParam(Object param) {
// 		this.param = param;
// 	}
// 	public String getSqlid() {
// 		return sqlid;
// 	}
// 	public void setSqlid(String sqlid) {
// 		this.sqlid = sqlid;
// 	}
// 	
// }


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Collection;
import org.hibernate.Session;
import org.hibernate.jdbc.Work;
import org.springframework.stereotype.Component;
import com.ea.core.orm.handle.AbstractORMHandle;
import com.ea.core.orm.handle.ORMConstants;
import com.ea.core.orm.handle.ORMHandle;
import com.ea.core.orm.handle.dto.ORMParamsDTO;
/**
 * Copyright 2014 伊永飞
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ea.core.orm.handle.impl;




/**
 * SQL执行，通过Hibernate完成，用于数据的新增或更新
 * @author yiyongfei
 *
 */
@Component
public class HibernateSqlORMHandle extends AbstractORMHandle {
    
	public HibernateSqlORMHandle() {
		super(ORMConstants.ORM_LEVEL.H_SQL.getCode());
	}

	@Override
	protected Object execute(ORMParamsDTO dto) throws Exception {
		// TODO Auto-generated method stub
		Session session = this.getHibernateSessionFactory().getCurrentSession();
// Path: architecture-orm/src/main/java/com/ea/core/orm/handle/AbstractORMHandle.java
// public abstract class AbstractORMHandle implements ORMHandle, ApplicationContextAware {
// 	protected ApplicationContext context = null;
// 	
//     @Autowired
//     private SqlSessionTemplate mybatisSessionTemplate;
//     @Autowired
//     private SessionFactory hibernateSessionFactory;
//     
// 	private String level;
// 	private ORMHandle nextHandle;
// 	
// 	public AbstractORMHandle(String level){
// 		this.level = level;
// 	}
// 	
// 	/**
// 	 * 符合当前Level，则执行DB操作，否则交由下个Handle去执行
// 	 */
// 	public final Object handle(String level, ORMParamsDTO dto) throws Exception {
// 		if(this.level.equals(level)){
// 			return this.execute(dto);
// 		} else {
// 			this.setNextHandle();
// 			if(this.nextHandle != null){
// 				return this.nextHandle.handle(level, dto);
// 			} else {
// 				throw new Exception("必须设置ORMHandle处理当前请求");
// 			}
// 		}
// 	}
// 	
// 	/**
// 	 * 执行DB操作
// 	 * @param dto
// 	 * @return
// 	 * @throws Exception
// 	 */
// 	protected abstract Object execute(ORMParamsDTO dto) throws Exception;
// 	
// 	/**
// 	 * 设置下个Handle，子类设置，如果是最后一个Handle，不设置
// 	 */
// 	public abstract void setNextHandle();
// 
// 	protected SqlSessionTemplate getMybatisSessionTemplate() {
// 		return mybatisSessionTemplate;
// 	}
// 
// 	protected SessionFactory getHibernateSessionFactory() {
// 		return hibernateSessionFactory;
// 	}
// 	
// 	public void setApplicationContext(ApplicationContext applicationContext) {
// 		// TODO Auto-generated method stub
// 		context = applicationContext;
// 	}
// 	
// 	protected void setNextHandle(ORMHandle nextHandle){
// 		this.nextHandle = nextHandle;
// 	}
// 
// }
// 
// Path: architecture-orm/src/main/java/com/ea/core/orm/handle/ORMHandle.java
// public interface ORMHandle {
// 
// 	public Object handle(String level, ORMParamsDTO dto) throws Exception;
// }
// 
// Path: architecture-orm/src/main/java/com/ea/core/orm/handle/dto/ORMParamsDTO.java
// public class ORMParamsDTO implements Serializable{
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 1L;
// 	
// 	private Object param;
// 	private String sqlid;
// 	
// 	public Object getParam() {
// 		return param;
// 	}
// 	public void setParam(Object param) {
// 		this.param = param;
// 	}
// 	public String getSqlid() {
// 		return sqlid;
// 	}
// 	public void setSqlid(String sqlid) {
// 		this.sqlid = sqlid;
// 	}
// 	
// }


// Path: architecture-orm/src/main/java/com/ea/core/orm/handle/impl/HibernateSqlORMHandle.java
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Collection;
import org.hibernate.Session;
import org.hibernate.jdbc.Work;
import org.springframework.stereotype.Component;
import com.ea.core.orm.handle.AbstractORMHandle;
import com.ea.core.orm.handle.ORMConstants;
import com.ea.core.orm.handle.ORMHandle;
import com.ea.core.orm.handle.dto.ORMParamsDTO;

/**
 * Copyright 2014 伊永飞
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ea.core.orm.handle.impl;




/**
 * SQL执行，通过Hibernate完成，用于数据的新增或更新
 * @author yiyongfei
 *
 */
@Component
public class HibernateSqlORMHandle extends AbstractORMHandle {
    
	public HibernateSqlORMHandle() {
		super(ORMConstants.ORM_LEVEL.H_SQL.getCode());
	}

	@Override
	protected Object execute(ORMParamsDTO dto) throws Exception {
		// TODO Auto-generated method stub
		Session session = this.getHibernateSessionFactory().getCurrentSession();
		final ORMParamsDTO tmp = dto;