2009-07-21 44 views
0

我使用ibator eclipse插件1.2.1。我的RDBMS是MySQL 5.1。我有一个ibator配置文件,如下图所示:ibatis ibator Java代码生成问题

 <?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 com.xxx.core.domain.account和企业人事类账户类。 xxx.core.domain.personel。我怎么能这样做? (在ibator中,我们可以在table标签上放置schema =“myschema”,但MySQL不支持schema)谢谢。

回答

0

我找到了解决方案。 runtimeSchema(是否数据库支持架构或没有也并不重要,这只是工作。)可以被用于此目的,例如:

<table tableName="account" domainObjectName="Account"> 
    <property name="runtimeSchema" value="account" /> 
</table> 

然而ibator预先考虑runctimeSchema每个表格。它会产生account.account作为一个表名(而不是只是帐户),这将无法正常工作。但是你可以写一个脚本来删除所有的前缀。