我爱oo,我爱java

交流blog QQ:421057986 oofrank@donews

使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案


1:abator下载:http://ibatis.apache.org/abator.html
2:将abator安装到eclipse中
3:此时可以新建一种文件类型:Abator for iBATIS Configuration File,建立一个
4:在 jdbcConnection 中设置要mapping的数据库的jdbc连接
  classPathEntry 是你的jdbc driver类路径
5:javaModelGenerator,sqlMapGenerator,daoGenerator 分别设置 java dataObject、sql mapping文件和 DAO 接口、实现类的生成位置:targetPackage 目标包,targetProject:eclipse项目
6:daoGenerator 中可以设置属性  type: ibatis 或 spring 指定生成的dao实现类是使用com.ibatis.dao.client.template.SqlMapDaoTemplate
还是
org.springframework.orm.ibatis.support.SqlMapClientDaoSupport
7: table 中 tableName 指定要处理的表名
  可以有多个table
8:table中可以包含子元素 generatedKey: 使Insert方法可以返回值--由指定的column mapping
9:generatedKey中的sqlStatement属性可以是获取sequence的SQL,也可以是获取自增值的SQL
  比如:Oracle的 select theSequence.nextVal from dual
       SQLServer的 SELECT @@IDENTITY as  column_name
10:保存文件,选中文件,右键菜单选择Generate iBATIS Artifacts! ok...



使用abtor生成的iBatis代码出现xml解析错误的解决方案
如果按上述方式生成的代码有xml解析错误:  请下载这个

注意,该文件名为Abator.rar.txt实际是一个rar文件,只是上传服务器有文件类型限制 所以只好加了扩展名txt。
请去掉.txt后解压。

使用
org.apache.ibatis.abator.core_0.5.1.jar
替换调你的 eclipse\plugins 的同名文件 即可。

然后重新生成代码。 OK 应该可以咯....

我改了一点代码,需要可以留言。

posted on 2006-01-21 13:51 兼听则明 阅读(9047) 评论(12)  编辑  收藏 所属分类: java

评论

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案 2006-03-28 21:12 andyking

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE abatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN"
"http://ibatis.apache.org/dtd/abator-config_1_0.dtd">

<abatorConfiguration>
<abatorContext> <!-- TODO: Add Database Connection Information -->
<jdbcConnection driverClass="net.sourceforge.jtds.jdbc.Driver"
connectionURL="jdbc:jtds:sqlserver://localhost:1433/test;tds=8.0;lastupdatecount=true"
userId="sa"
password="">
<classPathEntry location="D:/tools/driver/jtds-1.2.jar" />
</jdbcConnection>

<javaModelGenerator targetPackage="com.ibatis" targetProject="." />
<sqlMapGenerator targetPackage="com.ibatis.sqlmap" targetProject="." />
<daoGenerator type="IBATIS" targetPackage="com.ibatis" targetProject="." />

<table schema="" tableName="dbo.user_property">
<generatedKey sqlStatement="SELECT @@IDENTITY as column_name" identity="true" column=""/>
</table>

</abatorContext>
</abatorConfiguration>

  回复  更多评论   

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案 2006-03-28 21:14 andyking

Generation Warnings Occured
Table dbo.user_property does not exist, or contains only LOB fields
请问大哥这是什么原因!明明数据库里面有这张表!为什么不能生成!  回复  更多评论   

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案 2006-03-29 09:28 oofrank

@andyking
<table schema="" tableName="dbo.user_property">
改成
<table schema="dbo" tableName="user_property">
试试

我看你的没什么问题  回复  更多评论   

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案 2006-06-13 13:33 tedeyang

我也碰到过xml解析错误的现象。后来发现是ibatis的配置中没有打开namespace这个选项,要这样
<sqlMapConfig>
<settings
useStatementNamespaces="true"
/>
...
不知道你指的错误是不是类似的情况?

另外,我不太明白abator自动生成的xxxExample类和xxxselectByExample()怎么使用,能贴一段示例代码吗?

期待您的回信:tedeyang@msn.com  回复  更多评论   

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案 2006-12-03 17:56 houya

对于字段数不是很多的表abator生成的xml文件包含insert update select 等方法。
而对于字段数很多的表,abator确只能生成resultMap和动态条件,其他的insert和update等都没有。请问这是为什么啊。  回复  更多评论   

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案 2007-09-19 17:11 china_world

ORA-00604: error occurred at recursive SQL level 1
ORA-12705: Cannot access NLS data files or invalid environment specified

ORA-00604: error occurred at recursive SQL level 1
ORA-12705: Cannot access NLS data files or invalid environment specified

请问这个如何解决啊 谢谢!!

  回复  更多评论   

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案 2009-08-20 18:09 fieldwolf2

myeclipse连接oracle出现ora-12705错误的解决办法: MyEclipse DB Brower建立oracle数据库连接的时候,报出下面的错误. java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1 java.sql.SQLException: ORA-12705: invalid or unknown NLS parameter value specified 修改eclipse\eclipse.ini中的-Duser.language=*保持与windows XP控制面板中"区域和语言选项"中选定的语言区域一至; 如:将"-Duser.language=en"修改为"-Duser.language=zh"
  回复  更多评论   

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案 2014-06-25 21:58

个  回复  更多评论   

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案 2015-03-24 14:26 陈春熖

The specified target project directory fgms_easyui does not exist  回复  更多评论   

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案 2015-04-02 10:25 generation warning occured

Run complete With Warning
Reasion:
generation warning occured这个是怎么回事?  回复  更多评论   

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案 2016-03-08 18:52 赵国栋

我生成成功了。可是当我想 拼写 WHERE *** OR *** 的时候,我找不到相关的方法。只有
is null
not is null
=
>=
<=
等一些 工具方法。并且他们都是 and 的关系。
请楼主看到后赐教。!谢谢了。  回复  更多评论   

# re: 使用abator自动生成ibatis代码的经验 及碰到的问题的解决方案[未登录] 2016-08-03 11:27 minmin

请问下:自动生成的时候 生成java文件和sqlMap文件少了个字段是怎么回事,  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航: