spring+mybatis用ehcache.xml怎么配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring+mybatis用ehcache.xml怎么配置相关的知识,希望对你有一定的参考价值。

参考技术A package com.zxh.customer.hashmap.dao;
import java.util.List;
import java.util.Map;
/**
*
* @author Administrator
*
* @param <T>
*/
public interface IBaseDao
/**
* 单表插入记录
* @param obj
*/
public <T> int insert(String _mybitsId, T obj);
/**
* 更新单表
* @param obj
*/
public <T> int update(String _mybitsId, T obj);
/**
* 删除记录
* @param clz
* @param id
*/
public <T> int delete(String _mybitsId, T obj);

/**
*
* 返回查询一览表的信息
* @param <T>
* @param _mybitsId mybatis中对应业务标识
* @param _params
* @return
*/
public <T> List<T> query(String _mybitsId, Map<String, Object> _params);
/**
* 查询相关列表信息
* @param <T> 返回数据
* @param id mybatis中对应业务标识
* @param _params
* @return
*/
public <T> List<T> query(String _mybitsId, Object _params);
/**
* 查询单个数据
* @param queryString
* @param object
* @return
*/
public Object queryOne(String queryString, Object object);


package com.zxh.customer.hashmap.dao;
import java.sql.Connection;
import java.util.List;
import java.util.Map;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;
import com.googlecode.ehcache.annotations.Cacheable;
import com.googlecode.ehcache.annotations.TriggersRemove;
@Repository("baseDao")
public class BaseDaoImpl extends SqlSessionDaoSupport implements IBaseDao
/**
* 获取相关的数据库连接
*/
public Connection getConnection()
return getSqlSession().getConnection();

@TriggersRemove(cacheName = "springEhcache", removeAll = true)
public <T> int delete(String _mybitsId, T obj)
return getSqlSession().delete(_mybitsId, obj);

@TriggersRemove(cacheName = "springEhcache", removeAll = true)
public <T> int insert(String _mybitsId, T obj)
return getSqlSession().insert(_mybitsId, obj);

@TriggersRemove(cacheName = "springEhcache", removeAll = true)
public <T> int update(String _mybitsId, T obj)
return getSqlSession().update(_mybitsId, obj);

@Cacheable(cacheName = "springEhcache")
public <T> List<T> query(String _mybitsId, Map<String, Object> _params)
return getSqlSession().selectList(_mybitsId, _params);

@Cacheable(cacheName = "springEhcache")
public <T> List<T> query(String _mybitsId, Object _params)
return getSqlSession().selectList(_mybitsId, _params);

@Cacheable(cacheName = "springEhcache")
public Object queryOne(String _mybitsId, Object object)
return getSqlSession().selectOne(_mybitsId, object);



<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zxh.customer.hashmap.model.user">
<select id="selectUserById" parameterType="hashmap" resultType="hashmap">
SELECT CUST_ID, CUST_NAME FROM CUST WHERE
CUST_ID = #custId
</select>
<select id="selectUsersByName" parameterType="hashmap"
resultType="hashmap">
SELECT CUST_ID, CUST_NAME FROM CUST WHERE
CUST_NAME =
#custName
</select>
<insert id="insertUser" parameterType="hashmap">
insert into cust(cust_id,
cust_name) values(seq_cust.nextval, #custName)
</insert>
<delete id="deleteUser" parameterType="hashmap">
delete from cust where
cust_id = #custId
</delete>
<update id="updateUser" parameterType="hashmap">
update cust set cust_name
= #custName where cust_id = #custId
</update>
</mapper>

package com.zxh.customer.hashmap.service;
public interface IBaseService


附上出处链接:http://blog.csdn.net/etttttss/article/details/17245507

MyBatis - Spring框架整合