Tag: ibatis

从单个对象inheritance的不同类型的集合与单个超级对象集合

想象一下以下场景。 class Shape { // methods of Class Shape } class Circle extends Shape { // methods of Class Shape // methods of Class Circle } class Square extends Shape { // methods of Class Shape // methods of Class Square } class Canvas // This class should a bucket of objects that belong to […]

带有#in order by子句的ibatis内联参数

下面是我的ibatis地图配置, select * from contact salary like ‘%’ order by #orderby#, #orderby2# 这是我的pojo package com.nik; public class Contact { private String firstName; private String lastName; private String email; private String salary; private String mobile; private String orderby; private String orderby2; private int id; public Contact() {} public Contact( String firstName, String lastName, String email) { […]

使用Ibatis 2.3重新获取CLOB数据

我正在尝试从oracle数据库中检索clob数据,如reports.xml中所示。我正在使用oracle jdbc驱动程序版本“ Oracle JDBC驱动程序版本 – 10.0.2.0.0 ”。 以下是我收到的错误,请告诉我,如何解决这个问题。 2011-08-31 13:03:40,790 WARN [org.apache.struts.chain.commands.AbstractExceptionHandler] (http-10.12.230.222-8080-1) Unhandled exception com.ibatis.common.jdbc.exception.NestedSQLException: — The error occurred in sa/mobily/telecop/dao/config/GenericReportQuery.xml. — The error occurred while applying a parameter map. — Check the runReportQuery-InlineParameterMap. — Check the parameter mapping for the ‘QUERY’ property. — Cause: java.sql.SQLException: Data size bigger than max size for this […]

在Mybatis迁移工具中的一个事务中运行多个mysql语句

我正在使用Mybatis迁移工具来维护我们数据库的架构,但是我遇到了以下问题。 目前,如果我们在迁移中使用多个语句,则它们分别在单独的事务中运行。 因此,如果我想要更改2个表(或运行多个语句)作为function的一部分并且其中一个中断,则必须手动还原任何首先运行的表。 但是,如果所有语句都成功完成,则mybatis迁移仅在changelog表中标记为完成。 这实在令人沮丧,因为如果整个迁移不是自治的,就无法维持一个常量的db状态。 设置 这是我们的测试数据库的mybatis mygration的(相关)设置。 ## JDBC connection properties. driver=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/gamealert_test?allowMultiQueries=true username=gamealert password=******** # If set to true, each statement is isolated # in its own transaction. Otherwise the entire # script is executed in one transaction. auto_commit=false # This controls how statements are delimited. # By default statements are delimited by […]

使用ibatis将HashMap值插入表中

我在http://old.nabble.com/insert-statement-td21157498.html上找到了这个。我想做同样的事情。我的表中有两列。我可以通过映射hashmap键来插入哈希映射值到列名。现在我想把键值对放在表中,而不管键名。 从上面的链接粘贴。 我想编写一个动态插入语句,但字段和值都是动态的。 我的意思是 insert into table_one ( !!! dynamic list of keys from the HashMap ) values ( !!! values );

mybatis参数替换如何在@SelectProvider中工作

我inheritance了一些我想要理解的代码,而我在@SelectProvider上找到的任何搜索都发现了很多东西。 Java DAO @SelectProvider(type = CategoryDaoSelectProvider.class, method = “findByParentIdAndName”) Category findByParentIdAndName(@Param(“parentId”) Long parentId, @Param(“name”) String name); 选择提供商 public class CategoryDaoSelectProvider { public static String findByParentIdAndName(Map params) { Long parentId = (Long)params.get(“parentId”); // WHY IS THIS HERE??? StringBuffer buffer = new StringBuffer(); buffer.append(“SELECT COUNT(id) FROM Category “); if (parentId == null) { buffer.append(“WHERE parentId IS NULL […]

MyBatis 3.0.5和映射器加载问题

我正在使用MyBatis 3.0.5,我遇到了将映射器加载为资源的问题。 我使用的是Windows 7 64,我使用Eclipse Indigo 64bit和jdk7 64. MyBatis在Grizzly Web容器(在其中实现了具有jersey框架的rest服务)独立实例中初始化。 我有相同的映射器只用于测试,第一个是加载,第二个不起作用。 错误: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ### The error may exist in src/main/java/com/izs/mybatis/FormMapper.xml ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource src/main/java/com/izs/mybatis/FormMapper.xml at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8) at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:32) at com.izs.Main.initMyBatis(Main.java:114) at com.izs.Main.main(Main.java:80) Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. […]

如何对扩展SqlMapClientDaoSupport的DAO进行unit testing

Spring DA有助于编写DAO。 当使用iBATIS作为持久性框架并扩展SqlMapClientDaoSupport时,应该为DAO设置SqlMapClient模拟,但我不能这样做。 SqlMapClientTemplate不是一个接口,EasyMock不能为它创建一个模拟。

PostgreSQL – 整数最佳实践

最近在Web应用程序上工作,我决定在数据模型中使用integer []。 有2个表,一个有文章数据,另一个有标签(标签ID和描述),决定标签ID,文章将在article.tags integer []列中标记。 正如Milen A. Radev指出: 提示:数组不是集合; 搜索特定的数组元素可能是数据库错误设计的标志。 考虑为每个将成为数组元素的项使用一个单独的表。 这将更容易搜索,并且可能更好地扩展到大量元素。 不仅如此,但是必须使用JDBC和iBatis来处理整数[],我应该说“有趣”。 目前,我可以完成我必须做的工作实施。 为了简单起见,它可能会使用一个存储article.id和tag.id关系的单独表来重新工作。 最后,我很困惑的是整数[]最好用于什么语境? 我想我已经找到了最好的方法。

使用MyBatis调用Oracle存储过程

我正在从SQL Server 2008将数据库移动到Oracle,但无法使MyBatis工作。 给出以下示例: UserMapper.xml (示例) {CALL GetUsers()} UserDAO.java public interface UserDAO { public List getUsers(); } SQL Server过程 CREATE PROCEDURE [dbo].[GetUsers] AS BEGIN SET NOCOUNT ON; SELECT userId, firstName, lastName FROM Users END …适用于SQL Server 2008.有人可以向我解释如何从UserMapper.xml调用Oracle过程(与上面的SQL Server过程具有相同的名称和列)并使用Oracle游标填充我的User类? 这是我试过的: {CALL GetUsers(#{resultSet,mode=OUT,jdbcType=CURSOR,resultMap=UserResult})} 我收到此错误: Caused by: org.apache.ibatis.reflection.ReflectionException: Could not set property ‘resultSet’ of ‘class java.lang.Class’ with value […]