ibatis

springboot中使用h2数据库(内存模式)

痞子三分冷 提交于 2019-12-05 19:17:16
使用H2的优点,不需要装有服务端和客户端,在项目中包含一个jar即可,加上初始化的SQL就可以使用数据库了 在springboot中引入,我的版本是2.1.4,里面就包含有h2的版本控制 <!-- 集成h2数据库 --> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> 在pom文件中,一般我都办好了下面一段 <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> </configuration> </plugin> </plugins> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/**</include> </includes> <filtering>false</filtering> </resource> <resource>

Specify IBatis query timeout

不打扰是莪最后的温柔 提交于 2019-12-05 18:22:41
There is a way to specify IBatis query timeout using oracle jdbc and Java? Thanks From the iBatis manual : in the <settings> element : defaultStatementTimeout (iBATIS versions 2.2.0 and later) This setting is an integer value that will be applied as the JDBC query timeout for all statements. This value can be overridden with the “statement” attribute of any mapped statement. If not specified, no query timeout will be set unless specified on the “statement” attribute of a mapped statement. The specified value is the number of seconds the driver will wait for a statement to finish. Note that not

线上的一次栈溢出问题排查 StackOverflowError

痞子三分冷 提交于 2019-12-05 16:59:14
栈溢出的原因 在解决栈溢出问题之前,我们首先需要知道一般引起栈溢出的原因,主要有以下几点: 是否有递归调用,循环依赖调用 是否有大量循环或死循环 全局变量是否过多 局部变量过大,如:数组、List、Map数据过大 问题现象 我们一个很老的接口(近一年没有动过)在线上运行一段时间后报了 StackOverflowError 栈溢出,其他接口又能正常提供服务,错误日志: java.lang.StackOverflowError org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1303) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:977) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org

iBatis Discriminator on Insert

a 夏天 提交于 2019-12-05 16:44:22
问题 I have an abstract class Example and concrete subclasses to go along with it. I used a discriminator to pull data out of the database, like so: <resultMap id="ExampleResultMap" class="Example"> <discriminator column="stateCode" javaType="java.lang.String"> <subMap value="AL" resultMap="AlabamaStateResultMap"/> <subMap value="AR" resultMap="ArkansasStateResultMap"/> [...] </discriminator> </resultMap> <resultMap extends="ExampleResultMap" id="AlabamaStateResultMap" class="AlabamaState"/>

How does the mybatis parameter replacement work in @SelectProvider

人盡茶涼 提交于 2019-12-05 11:49:05
I've in inherited some code that I'm trying to understand and any searching I do to find something on @SelectProvider turns up a whole lot of nothing. Java DAO @SelectProvider(type = CategoryDaoSelectProvider.class, method = "findByParentIdAndName") Category findByParentIdAndName(@Param("parentId") Long parentId, @Param("name") String name); Select Provider public class CategoryDaoSelectProvider { public static String findByParentIdAndName(Map<String, Object> params) { Long parentId = (Long)params.get("parentId"); // WHY IS THIS HERE??? StringBuffer buffer = new StringBuffer(); buffer.append(

MyBatis 3.0.5 and mappers loading problem

▼魔方 西西 提交于 2019-12-05 10:58:46
I'm using MyBatis 3.0.5 and I have problems about the loading of mappers as resources. I'm on Windows 7 64, I use Eclipse Indigo 64bit and jdk7 64. MyBatis is initialized in a Grizzly Web Container (where are implemented rest services with jersey framework) standalone instance. <mappers> <mapper url="file:///C:/Users/andrea/workspace/soap2rest/src/main/java/com/izs/mybatis/FormMapper.xml" /> <mapper resource="src/main/java/com/izs/mybatis/FormMapper.xml" /> </mappers> I have the same mappers only for testing, the first is loaded, the second doesn't work. Errors: org.apache.ibatis.exceptions

【Mybatis】- 工作流程

走远了吗. 提交于 2019-12-05 06:16:55
ORM:Object Relation Mapping:对象关系映射,通俗理解就是将一个对象相关属性和数据库数据进行关联(映射),传统我们对数据库数据的操作可以通过ORM框架转移到对对象的操作上来,这无疑有利于提高程序的开发效率和项目的可维护性,本质是对传统的JDBC操作高级封装 工作流程 mybatis通过sqlSessionFactory创建sqlSession, sqlSession表示应用程序与数据库的会话,当用户使用mapper.xml文件中配置的的方法时,mybatis首先会解析sql动态标签为对应数据库sql的形式,并将其封装进MapperStatement对象,然后通过executor将sql注入数据库执行,并返回结果 常见ORM框架:hibernate、mybatis mybatis主要通过两个配置文件(sqlMapConfig.xml和Mapper.xml),来配置数据库和对象的关系 sqlMapConfig.xml Mybatis全局配置文件,主要配置mybatis的环境参数、映射对象运行参数。 mybatis的环境参数:数据源配置、事务控制 映射对象运行参数:映射对象的别名设置、映射对象配置文件加载 案例: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE configuration PUBLIC "-/

How to manage read-only DB connections at an application level

谁说我不能喝 提交于 2019-12-05 06:16:41
问题 We are using Java/Spring/Ibatis/MySql. Is there a way with these technologies to manage read-only connections at an application level. I am looking to add an extra layer of safeguarding on top of having read-only MySql users. It would be nice if BasicDataSource or SqlMapClientTemplate provided configuration for read-only connections. Otherwise, it seems like I'm left to only MySql read users and enforcing interfaces with only read methods. Thanks 回答1: for example Connection#CreateStatement

iBatis create an array of multiple annotations (annotation reuse)

删除回忆录丶 提交于 2019-12-05 05:17:16
问题 My greetings! I am pretty new to iBatis and I have faced such kind of optimization problem: I have two absolutely identical @Results with just 1 parameter in difference. Is there any way I could create some sort of annotation-array to reuse it for mapping? The source looks like that: public static interface StoreMapper { @Select("SELECT * FROM STORE WHERE STORE_NUMBER = #{storeNumber}") @Results(value = { @Result(property="storeNumber", column="STORE_NUMBER"), @Result(property="districtId",

mybatis插入出现org.apache.ibatis.executor.ExecutorException: No setter found for the keyProperty 'xxx'异常的原因

做~自己de王妃 提交于 2019-12-05 03:11:15
确定有setter方法,问题其实是xml文件中,insert的主键的列名写错了,如下,一开始写成ComId <insert id="insertCom" parameterType="Comment" useGeneratedKeys="true" keyProperty="comId"> 来源: https://www.cnblogs.com/zxcoder/p/11901593.html