tags:

views:

1829

answers:

3

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.

A: 

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:

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

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.

Gok Demir
A: 

this is the XML i wrote to generte.. but i am getting error Unexpected error while running Ibator. Exception getting JDBC Driver

<javaModelGenerator targetPackage="com.citi.cmb.model" targetProject="IbatisTestApplication" />
<sqlMapGenerator targetPackage="com.citi.cmb.sql" targetProject="IbatisTestApplication" />
<daoGenerator targetPackage="com.citi.cmb.dao" targetProject="IbatisTestApplication" type="GENERIC-CI" />
<table schema="CASB_DEV" tableName="*.*"/>

  </ibatorContext>

Sam
A: 

thanks gok, well i m new in ibatis, i was trying to use ibator to generate SqlMapper , Java model and DAO. I tried with eclipse plug in and also with the ant task but both the the time i got error message " Unexpected error while running Ibator. Exception getting JDBC Driver ". i think it is some where related to configuration. i kept ibatis-3-core-3.0.0.200.jar , ibator.jar , classes12.jar or ojdbc14.jar in my project class path too.

Sam
You must have ibatorConfig.xml, SqlMapConfig.xml, and map1.xml, map2.xml so on. What dataase are you using? Where did you configure the database configuration. Please provide the database configuration file (ibatorConfig.xml).
Gok Demir