2009-07-21 1 views
0

Я использую плагин ibator eclipse 1.2.1. Моя СУБД - это 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.xxx.core.domain.account и классе Кадрового в ком. xxx.core.domain.personel. Как я мог это сделать? (В ibator мы можем поместить schema = "myschema" в тег таблицы, но MySQL не поддерживает схему) Спасибо.

ответ

0

Я нашел решение. runtimeSchema (. Поддерживают ли база данных схемы или нет это не важно, просто работает.) может быть использовано для этой цели, например:

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

Однако ibator присоединяет runctimeSchema к каждой таблице. Он будет производить account.account как имя таблицы (а не только учетную запись), которая не будет работать. Но вы можете написать скрипт для удаления всех префиксов.