ibatis ibator Java代码生成问题
我使用 ibator eclipse 插件 1.2.1。 我的 RDBMS 是 MySQL 5.1。 我有一个 ibator 配置文件,如下所示:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ibatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Apache iBATIS Ibator Configuration 1.0//EN" "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd" >
<ibatorConfiguration>
<classPathEntry location="/mysql-connector-java-5.1.7-bin.jar"/>
<ibatorContext defaultModelType="flat" id="context1" targetRuntime="Ibatis2Java5">
<jdbcConnection connectionURL="jdbc:mysql://localhost:3306/database" driverClass="com.mysql.jdbc.Driver" password="pass" userId="root"/>
<javaModelGenerator targetPackage="com.xxx.core.domain" targetProject="Myproject">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.xxx.core.dao.ibatis.maps" targetProject="Myproject">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<daoGenerator targetPackage="com.xxx.core.dao" targetProject="Myproject" type="SPRING">
<property name="enableSubPackages" value="true"/>
<property name="methodNameCalculator" value="extended"/>
</daoGenerator>
<table tableName="account" domainObjectName="Account"/>
<table tableName="personel" domainObjectName="Personel"/>
</ibatorContext>
</ibatorConfiguration>
所有生成的代码都在 com.xxx.core.domain 中,但我想要 com.xxx.core.domain.account 中的 Account 类和 com.xxx.core.domain.personel 中的 Personel 类。 我怎么能这么做呢? (在 ibator 中,我们可以将 schema="myschema" 放在表标签上,但 MySQL 不支持 schema)谢谢。
I use ibator eclipse plugin 1.2.1. My RDBMS is MySQL 5.1. I have a ibator config file as shown below:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ibatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Apache iBATIS Ibator Configuration 1.0//EN" "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd" >
<ibatorConfiguration>
<classPathEntry location="/mysql-connector-java-5.1.7-bin.jar"/>
<ibatorContext defaultModelType="flat" id="context1" targetRuntime="Ibatis2Java5">
<jdbcConnection connectionURL="jdbc:mysql://localhost:3306/database" driverClass="com.mysql.jdbc.Driver" password="pass" userId="root"/>
<javaModelGenerator targetPackage="com.xxx.core.domain" targetProject="Myproject">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.xxx.core.dao.ibatis.maps" targetProject="Myproject">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<daoGenerator targetPackage="com.xxx.core.dao" targetProject="Myproject" type="SPRING">
<property name="enableSubPackages" value="true"/>
<property name="methodNameCalculator" value="extended"/>
</daoGenerator>
<table tableName="account" domainObjectName="Account"/>
<table tableName="personel" domainObjectName="Personel"/>
</ibatorContext>
</ibatorConfiguration>
All generated codes are in com.xxx.core.domain but I want Account class in com.xxx.core.domain.account and Personel class in com.xxx.core.domain.personel. How could I do that? (In ibator we can put schema="myschema" on table tag but MySQL does not support schema) Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了解决方案。 runtimeSchema(数据库是否支持模式。这并不重要。它只是有效)可以用于此目的,例如:
但是 ibator 将 runctimeSchema 前置到每个表。 它将生成 account.account 作为表名(而不仅仅是帐户),这是行不通的。 但是您可以编写一个脚本来删除所有前缀。
I found the solution. runtimeSchema (whether database support schema or not. It does not important. It just works) can be used for this purpose for example:
However ibator prepends runctimeSchema to every table. It will produce account.account as a table name (instead of just account) which will not work. But you can write a script to delete all prefixes.
如果您正在寻找完整的(工作)示例,我发现 http://ganeshtiwaridotcomdotnp.blogspot.com/2011/05/tutorial-on-ibatis-using-eclipse-ibator_31.html 可能对您有帮助。
本文介绍了使用 ibator 插件配置 ibatis 的步骤。 以及带有可下载代码的工作示例。
If you are looking for complete (working) example then, i found http://ganeshtiwaridotcomdotnp.blogspot.com/2011/05/tutorial-on-ibatis-using-eclipse-ibator_31.html might help you.
This article explains steps for configuring ibatis with ibator plugin. And working sample examples with downloadable code.