Date | Version | Changes |
---|---|---|
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 ( |
...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> |