ibatis

How to specify IN param type with annotation-configured MyBatis

ぃ、小莉子 提交于 2019-12-08 05:55:56
问题 It seems I need to explicitly tell MyBatis what db-type to use for java.util.Date IN parameters if I want to able to pass null values. But I can't find a way of doing that. I tried different variations of following with no luck: @Select("<script>SELECT ... WHERE ... " + "<if test='#{dateFrom,jdbcType=TIMESTAMP} != null'>" + " AND date > #{dateFrom,jdbcType=TIMESTAMP}" + "</if></script>") List<MyType> getRecords(@Param("dateFrom") dateFrom) How does one specify a parameter type when using

What is the best way to iterate over a large result set in JDBC/iBatis 3?

陌路散爱 提交于 2019-12-08 05:13:17
问题 We're trying to iterate over a large number of rows from the database and convert those into objects. Behavior will be as follows: Result will be sorted by sequence id, a new object will be created when sequence id changes. The object created will be sent to an external service and will sometimes have to wait before sending another one (which means the next set of data will not be immediately used) We already have invested code in iBatis 3 so an iBatis solution will be the best approach for

Inserting HashMap Values to a table using ibatis

和自甴很熟 提交于 2019-12-08 02:27:48
问题 I found this on http://old.nabble.com/insert-statement-td21157498.html I want to do the same thing .I have two columns in my table .I am able to insert hash map values by mapping the hashmap key to the column name.Now i want put the key values pairs in the table irrespective of key name. Pasted from the link above. I would like to write a dynamic insert statement, but both fields and values are dynamic. I mean <insert id="someIDhere" parameterClass="java.util.HashMap"> insert into table_one (

MyBatis学习整理0

China☆狼群 提交于 2019-12-07 19:17:22
学习java的基本都会“ssh”,我也不例外,其中就包括了hibernate,当时感觉挺神奇的,去年开始接触mybatis,一对比发现,这mybatis有不少优点。 下面分享一下我在学习mybatis的时候整理的内容。 1、组织 基本配置的xml 映射关系的xml 映射的接口 获取`session`的工具类 实体类 这里需要注意的是: 两个xml文件都是使用dtd进行约束描述的,(dtd文件不一样); 基本配置的xml文件配置项是有顺序的,properties,settings,typeAliases,typeHandlers,objectFactory,objectWrapperFactory,plugins,environments,databaseIdProvider,mappers; 映射配置可以使用xml也可以使用接口类,而且可以共存; 使用接口类进行映射配置,不需要写实现类,只需要在接口方法上进行注解配置即可; 接口上注解配置映射时,可以直接写sql,也可以使用单独的工具类提供sql,不同的注解配置; 对于使用单独工具类为注解接口提供sql的情况,需要在注解时为参数提供名字,同时工具类中使用`SQL`类,进行链式编程 2、实体类中的属性名和表中的字段名不一致时 当实体类中的属性名和表中的字段名不一致时

Auto-incrementation with HSQLDB (2.2.8) + DDLUtils

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 16:49:26
I want to use HSQLDB as an embedded database but am having trouble getting it to auto-increment . As far as I understand, [CALL] IDENTITY() can be used to get the last primary key value. However, experiments through both iBatis and HSQLDB's DatabaseManagerSwing continually return a 0 value. How can I get auto-incrementation to work with HSQLDB? Edit: I didn't mention that I'm using DDLUtils to autogenerate tables. The following does not suit HSQLDB: <?xml version="1.0"?> <!DOCTYPE database SYSTEM "http://db.apache.org/torque/dtd/database.dtd"> <database name="testdb"> <table name="users"> <!--

Specify IBatis query timeout

你。 提交于 2019-12-07 16:48:53
问题 There is a way to specify IBatis query timeout using oracle jdbc and Java? Thanks 回答1: 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

What is the best way to iterate over a large result set in JDBC/iBatis 3?

瘦欲@ 提交于 2019-12-07 07:21:19
We're trying to iterate over a large number of rows from the database and convert those into objects. Behavior will be as follows: Result will be sorted by sequence id, a new object will be created when sequence id changes. The object created will be sent to an external service and will sometimes have to wait before sending another one (which means the next set of data will not be immediately used) We already have invested code in iBatis 3 so an iBatis solution will be the best approach for us (we've tried using RowBounds but haven't seen how it does the iteration under the hood). We'd like to

How to unit test a DAO that is extending SqlMapClientDaoSupport

心不动则不痛 提交于 2019-12-07 05:39:38
问题 Spring DA helps in writing DAOs. When using iBATIS as the persistence framework, and extending SqlMapClientDaoSupport, a SqlMapClient mock should be set for the DAO, but I can't do it. SqlMapClientTemplate is not an interface and EasyMock cannot creates a mock for it. 回答1: DAO and unit tests do not get along well ! That does not make sense to mock anything in a component that does not hold any business logic and is focused on database access. You should try instead to write an integration

看源码解决:org.apache.ibatis.binding.BindingException: Parameter &apos;0&apos; not found

元气小坏坏 提交于 2019-12-07 01:48:22
报错信息 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter '0' not found. Available parameters are [arg1, arg0, param1, param2] at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) at com.sun.proxy.$Proxy98.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230) at org.apache.ibatis.binding.MapperMethod.executeForMany