iBatis 工具

3 篇文章 0 订阅

Google

<script type="text/javascript"> google_ad_client = "pub-5033576919944123"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; //2007-10-24: csdn.blog google_ad_channel = "8548491739"; </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script language="JavaScript" type="text/javascript"> </script><script language="JavaScript1.1" type="text/javascript"> </script><script language="JavaScript1.2" type="text/javascript"> </script><script language="JavaScript1.3" type="text/javascript"> </script><script language="JavaScript" type="text/javascript"> </script> 

iBatis™ java-beans sources and sql-map config files generator

Генератор исходных текстов java-beans и sql-map конфигов для iBatis™

 

DateVersionChanges
2005/10/31
0.2.3
  • Fixed some mysql specific issues.
2004/12/24
0.2.2
  • New parameters "nobeans" and "nomaps" are added.
  • Processing of SQL definitions with multiple spaces is fixed
2004/10/12
0.2.0
  • SQL Maps 2.0 compatible.
2004/02/11
0.1.9
  • Parse of specific MySQL syntax is added.
  • Fixed a lot of bugs.
2004/01/16
0.1.8
  • Changed order of statements in generated sql-map file.
  • Added two new parameters "beansinc" and "mapsinc" for files containing user-defined code.
  • Added mapped-statement for record deletion.
2004/01/13
0.1.7
  • Fixed some bugs.
  • Added new parameters "beansout" and "mapsout".
  • Now runs on *nix systems.
2004/01/09
0.1.6
  • First public release

 

Download. Ver. 0.2.3 for iBatis SQL Maps 2.0
Download. Ver. 0.1.91 for iBatis SQL Maps 1.X


iBatis java-beans sources and sql-map config files generator.
Version 0.2.3

USAGE: sql2iBatis.pl -input=<sqlfile> [OPTIONS]
    -input=<sqlfile>  sql-file to parse
OPTIONS are:
    -package=<packageName>    optional package name (domain.company.project)
    -force          forces files regeneration
    -beansout       java-beans output folder
    -mapsout        sql-maps output folder
    -mapsinc        Extension of file containing user-defined mapped statements
    -beansinc       Extension of file containing user-defined java-beans code

NOTE:   File with an extension specified using the parameter -beansinc (e.g. 'UserProperties.xml.inc')
    must be located in sql-maps output folder. It's content will be inserted right after the generated
    mapped-statements in the destination file.

Please send bug reports and feature requests to alxeg@yandex.ru

 

Giving following SQL file as input:

CREATE TABLE USER_PROPERTY (
USER_ID BIGINT NOT NULL
, FIRST_NAME VARCHAR(100) DEFAULT ''
, LAST_NAME VARCHAR(100)
, BIRTH_DATE TIMESTAMP(8)
, PRIMARY KEY (USER_ID)
);

...produces java-bean file:

package org.mystuff.db;


// WARNING: This is an autogenerated file


public class UserProperty {

    // Constructors
    public UserProperty() {
    }
    public UserProperty(long _userId) {
        this.userId = _userId;
    }

    // Fields
    private String firstName;
    public String getFirstName() {
        return firstName;
    }
    public void setFirstName(String _firstName) {
        this.firstName = _firstName;
    }

    private java.util.Date birthDate;
    public java.util.Date getBirthDate() {
        return birthDate;
    }
    public void setBirthDate(java.util.Date _birthDate) {
        this.birthDate = _birthDate;
    }

    private String lastName;
    public String getLastName() {
        return lastName;
    }
    public void setLastName(String _lastName) {
        this.lastName = _lastName;
    }

    private long userId;
    public long getUserId() {
        return userId;
    }
    public void setUserId(long _userId) {
        this.userId = _userId;
    }

}
    

...and iBatis sql-map config file:

<?xml version='1.0'?>

<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
    "http://www.ibatis.com/dtd/sql-map-2.dtd">


<!-- WARNING: This is an autogenerated file -->

<sqlMap name="UserProperty">

    <cacheModel id="userproperty-cache" type="MEMORY">
        <flushInterval hours="24"/>
        <flushOnExecute statement="insertUserProperty"/>
        <flushOnExecute statement="updateUserProperty"/>
        <flushOnExecute statement="deleteUserProperty"/>
        <property name="reference-type" value="WEAK" />
    </cacheModel>

    <resultMap class="org.mystuff.db.UserProperty" id="userproperty-result" >
        <result property="firstName" column="FIRST_NAME" />
        <result property="birthDate" column="BIRTH_DATE" />
        <result property="lastName" column="LAST_NAME" />
        <result property="userId" column="USER_ID" />
    </resultMap>

    <select id="getUserProperty" resultClass="org.mystuff.db.UserProperty" parameterClass="org.mystuff.db.UserProperty" resultMap="userproperty-result" >
        <![CDATA[
            select * from USER_PROPERTY
            where  USER_ID = #userId#
        ]]>
    </select>

    <update id="updateUserProperty" parameterClass="org.mystuff.db.UserProperty" >
        <![CDATA[
            update USER_PROPERTY
            set  FIRST_NAME = #firstName# ,  BIRTH_DATE = #birthDate# ,  LAST_NAME = #lastName#
            where  USER_ID = #userId#
        ]]>
    </update>

    <insert id="insertUserProperty" parameterClass="org.mystuff.db.UserProperty" >
        <![CDATA[
            insert into USER_PROPERTY(FIRST_NAME, BIRTH_DATE, LAST_NAME, USER_ID)
            values(#firstName#, #birthDate#, #lastName#, #userId#)
        ]]>
    </insert>

    <delete id="deleteUserProperty" parameterClass="org.mystuff.db.UserProperty"  >
        <![CDATA[
            delete  from USER_PROPERTY
            where  USER_ID = #userId#
        ]]>
    </delete>

</sqlMap>
 

 

Рейтинг@Mail.ru
<script language="JavaScript" src="iBatis SQL Maps 2.0_files/163.htm" type="text/javascript"></script>  

<script type="text/javascript"> google_ad_client = "pub-5033576919944123"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; //2007-10-24: csdn.blog google_ad_channel = "8548491739"; </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值