读书人

ibatis-缓存应用示例

发布时间: 2012-07-15 20:20:06 作者: rapoo

ibatis-缓存使用示例

? ?ibatis缓存使用还是很简单的,除了一点。

?

? ?文档上告诉我cacheModelsEnabled默认为true,结果实验确发现ibatis-缓存应用示例必须手动设为true。如下:

?

?

<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE sqlMapConfig          PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"          "http://ibatis.apache.org/dtd/sql-map-config-2.dtd"><sqlMapConfig><!-- 坑爹啊,说是默认,可是我去掉就没缓存策略了 --><settings cacheModelsEnabled="true" /><!--Configure a built-in transaction manager. If you're using an appserver, you probably want to use its transaction manager and a manageddatasource--><transactionManager type="JDBC" commitRequired="false"><dataSource type="SIMPLE"><property name="JDBC.Driver" value="com.mysql.jdbc.Driver" /><property name="JDBC.ConnectionURL" value="jdbc:mysql://192.168.104.92:3306/test" /><property name="JDBC.Username" value="test" /><property name="JDBC.Password" value="test" /></dataSource></transactionManager><!--List the SQL Map XML files. They can be loaded from the classpath, asthey are here (com.domain.data...)--><sqlMap resource="com/mydomain/data/Account.xml" /><!--List more here... <sqlMap resource="com/mydomain/data/Order.xml"/><sqlMap resource="com/mydomain/data/Documents.xml"/>--></sqlMapConfig>

?

其他,到都简单,随便搜索理解即可。示例代码见附件。

读书人网 >开源软件

热点推荐