Author: jgbutler
Date: Sun Nov 8 04:08:23 2009
New Revision: 833820
URL: http://svn.apache.org/viewvc?rev=833820&view=rev
Log:
[ibator] tests for ibatis3 support
Added:
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/pom.xml
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/BaseClass.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/BaseInterface.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/FirstName.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/FirstNameTypeHandler.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/MyTime.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/MyTimeTypeHandler.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/resources/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/resources/CreateDB.sql
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/resources/ibatorConfig.xml
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/AbstractTest.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/conditional/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/conditional/java5/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/conditional/java5/ConditionalJava5Test.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/conditional/java5/UpdateByExampleTest.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/flat/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/flat/java5/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/flat/java5/FlatJava5Test.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/flat/java5/UpdateByExampleTest.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/hierarchical/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/hierarchical/java5/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/hierarchical/java5/HierarchicalJava5Test.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/hierarchical/java5/UpdateByExampleTest.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/miscellaneous/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/execute/miscellaneous/MiscellaneousTest.java
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/resources/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/resources/ibatortest/
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/resources/ibatortest/MapperConfig.xml
Added: ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/pom.xml
URL:
http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/pom.xml?rev=833820&view=auto
==============================================================================
--- ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/pom.xml (added)
+++ ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/pom.xml Sun Nov 8
04:08:23 2009
@@ -0,0 +1,87 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.ibatis.ibator</groupId>
+ <artifactId>ibator-systests-ibatis3</artifactId>
+ <version>1.2.2-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>ibator-systests-ibatis3</name>
+ <url>http://ibatis.apache.org/ibator.html</url>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.3</version>
+ <configuration>
+ <forkMode>always</forkMode>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.ibatis.ibator</groupId>
+ <artifactId>ibator-maven-plugin</artifactId>
+ <version>1.2.2-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>Generate iBATIS Artifacts</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <sqlScript>src/main/resources/CreateDB.sql</sqlScript>
+ <jdbcDriver>org.hsqldb.jdbcDriver</jdbcDriver>
+ <jdbcURL>jdbc:hsqldb:mem:aname</jdbcURL>
+ <jdbcUserId>sa</jdbcUserId>
+ <overwrite>true</overwrite>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.10</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ibatis</groupId>
+ <artifactId>ibatis-3-core</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ <version>2.5.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ <version>2.5.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.10</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added:
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/BaseClass.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/BaseClass.java?rev=833820&view=auto
==============================================================================
---
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/BaseClass.java
(added)
+++
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/BaseClass.java
Sun Nov 8 04:08:23 2009
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ibatortest.execute.miscellaneous;
+
+/**
+ * @author Jeff Butler
+ */
+public class BaseClass {
+ private String lastname;
+
+ /**
+ *
+ */
+ public BaseClass() {
+ super();
+ }
+
+ // these methods are final so that an error will be generated
+ // if the extended class tries to overwrite them. This
+ // will break the build as the generator should
+ // see a duplicate property.
+ // TODO - Make Final again once we figure out the maven classloading thing
+ public String getLastname() {
+ return lastname;
+ }
+
+ // TODO - Make Final again once we figure out the maven classloading thing
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+}
Added:
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/BaseInterface.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/BaseInterface.java?rev=833820&view=auto
==============================================================================
---
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/BaseInterface.java
(added)
+++
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/BaseInterface.java
Sun Nov 8 04:08:23 2009
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ibatortest.execute.miscellaneous;
+
+/**
+ * @author Jeff Butler
+ */
+public interface BaseInterface {
+
+}
Added:
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/FirstName.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/FirstName.java?rev=833820&view=auto
==============================================================================
---
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/FirstName.java
(added)
+++
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/FirstName.java
Sun Nov 8 04:08:23 2009
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ibatortest.execute.miscellaneous;
+
+/**
+ * @author Jeff Butler
+ *
+ */
+public class FirstName {
+
+ private String value;
+
+ /**
+ *
+ */
+ public FirstName() {
+ super();
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object arg0) {
+ if (arg0 == null) {
+ return false;
+ }
+
+ return value.equals(((FirstName)arg0).getValue());
+ }
+
+ @Override
+ public int hashCode() {
+ return value == null ? 0 : value.hashCode();
+ }
+
+}
Added:
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/FirstNameTypeHandler.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/FirstNameTypeHandler.java?rev=833820&view=auto
==============================================================================
---
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/FirstNameTypeHandler.java
(added)
+++
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/FirstNameTypeHandler.java
Sun Nov 8 04:08:23 2009
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ibatortest.execute.miscellaneous;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.TypeHandler;
+
+/**
+ * @author Jeff Butler
+ *
+ */
+public class FirstNameTypeHandler implements TypeHandler {
+
+ /**
+ *
+ */
+ public FirstNameTypeHandler() {
+ super();
+ }
+
+ public Object getResult(CallableStatement cs, int columnIndex)
+ throws SQLException {
+ FirstName answer = null;
+ String string = cs.getString(columnIndex);
+ if (string != null) {
+ answer = new FirstName();
+ answer.setValue(string);
+ }
+
+ return answer;
+ }
+
+ public Object getResult(ResultSet rs, String columnName)
+ throws SQLException {
+ FirstName answer = null;
+ String string = rs.getString(columnName);
+ if (string != null) {
+ answer = new FirstName();
+ answer.setValue(string);
+ }
+
+ return answer;
+ }
+
+ public void setParameter(PreparedStatement ps, int i, Object parameter,
+ JdbcType jdbcType) throws SQLException {
+ if (parameter == null) {
+ ps.setNull(i, jdbcType.TYPE_CODE);
+ } else {
+ FirstName firstName = (FirstName) parameter;
+ ps.setString(i, firstName.getValue());
+ }
+ }
+}
Added:
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/MyTime.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/MyTime.java?rev=833820&view=auto
==============================================================================
---
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/MyTime.java
(added)
+++
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/MyTime.java
Sun Nov 8 04:08:23 2009
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ibatortest.execute.miscellaneous;
+
+/**
+ * @author Jeff Butler
+ *
+ */
+public class MyTime {
+ private int hours;
+ private int minutes;
+ private int seconds;
+
+ /**
+ *
+ */
+ public MyTime() {
+ super();
+ }
+
+ public int getHours() {
+ return hours;
+ }
+
+ public void setHours(int hours) {
+ this.hours = hours;
+ }
+
+ public int getMinutes() {
+ return minutes;
+ }
+
+ public void setMinutes(int minutes) {
+ this.minutes = minutes;
+ }
+
+ public int getSeconds() {
+ return seconds;
+ }
+
+ public void setSeconds(int seconds) {
+ this.seconds = seconds;
+ }
+
+ @Override
+ public boolean equals(Object arg0) {
+ if (arg0 == null) {
+ return false;
+ }
+
+ MyTime other = (MyTime) arg0;
+
+ return this.hours == other.hours
+ && this.minutes == other.minutes
+ && this.seconds == other.seconds;
+ }
+
+ @Override
+ public int hashCode() {
+ return hours + minutes + seconds;
+ }
+
+}
Added:
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/MyTimeTypeHandler.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/MyTimeTypeHandler.java?rev=833820&view=auto
==============================================================================
---
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/MyTimeTypeHandler.java
(added)
+++
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/java/ibatortest/execute/miscellaneous/MyTimeTypeHandler.java
Sun Nov 8 04:08:23 2009
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ibatortest.execute.miscellaneous;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.util.Calendar;
+
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.TypeHandler;
+
+/**
+ * @author Jeff Butler
+ *
+ */
+public class MyTimeTypeHandler implements TypeHandler {
+
+ /**
+ *
+ */
+ public MyTimeTypeHandler() {
+ super();
+ }
+
+ public Object getResult(CallableStatement cs, int columnIndex)
+ throws SQLException {
+ MyTime answer = null;
+ Time time = cs.getTime(columnIndex);
+ if (time != null) {
+ answer = new MyTime();
+
+ Calendar c = Calendar.getInstance();
+ c.setTime(time);
+
+ answer.setHours(c.get(Calendar.HOUR_OF_DAY));
+ answer.setMinutes(c.get(Calendar.MINUTE));
+ answer.setSeconds(c.get(Calendar.SECOND));
+ }
+
+ return answer;
+ }
+
+ public Object getResult(ResultSet rs, String columnName)
+ throws SQLException {
+ MyTime answer = null;
+ Time time = rs.getTime(columnName);
+ if (time != null) {
+ answer = new MyTime();
+
+ Calendar c = Calendar.getInstance();
+ c.setTime(time);
+
+ answer.setHours(c.get(Calendar.HOUR_OF_DAY));
+ answer.setMinutes(c.get(Calendar.MINUTE));
+ answer.setSeconds(c.get(Calendar.SECOND));
+ }
+
+ return answer;
+ }
+
+ public void setParameter(PreparedStatement ps, int i, Object parameter,
+ JdbcType jdbcType) throws SQLException {
+ if (parameter == null) {
+ ps.setNull(i, jdbcType.TYPE_CODE);
+ } else {
+ MyTime myTime = (MyTime) parameter;
+ Calendar c = Calendar.getInstance();
+ c.set(Calendar.HOUR_OF_DAY, myTime.getHours());
+ c.set(Calendar.MINUTE, myTime.getMinutes());
+ c.set(Calendar.SECOND, myTime.getSeconds());
+
+ Time time = new Time(c.getTime().getTime());
+
+ ps.setTime(i, time);
+ }
+ }
+}
Added:
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/resources/CreateDB.sql
URL:
http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/resources/CreateDB.sql?rev=833820&view=auto
==============================================================================
---
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/resources/CreateDB.sql
(added)
+++
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/resources/CreateDB.sql
Sun Nov 8 04:08:23 2009
@@ -0,0 +1,101 @@
+drop table FieldsOnly if exists;
+drop table PKOnly if exists;
+drop table PKFields if exists;
+drop table PKBlobs if exists;
+drop table PKFieldsBlobs if exists;
+drop table FieldsBlobs if exists;
+drop table "awful table" if exists;
+drop table BlobsOnly if exists;
+
+create table FieldsOnly (
+ IntegerField int,
+ DoubleField double,
+ FloatField float
+);
+
+create table PKOnly (
+ id int not null,
+ seq_num int not null,
+ primary key(id, seq_num)
+);
+
+create table PKFields (
+ id1 int not null,
+ id2 int not null,
+ firstName varchar(20),
+ lastName varchar(20),
+ dateField date,
+ timeField time,
+ timestampField timestamp,
+ decimal30Field decimal(3, 0),
+ decimal60Field decimal(6, 0),
+ decimal100Field decimal(10, 0),
+ decimal155Field decimal(15, 5),
+ wierd$Field int,
+ primary key (id1, id2)
+);
+
+create table PKBlobs (
+ id int not null,
+ blob1 longvarbinary,
+ blob2 longvarbinary,
+ primary key (id)
+);
+
+create table PKFieldsBlobs (
+ id1 int not null,
+ id2 int not null,
+ firstName varchar(20),
+ lastName varchar(20),
+ blob1 longvarbinary,
+ primary key (id1, id2)
+);
+
+create table FieldsBlobs (
+ firstName varchar(20),
+ lastName varchar(20),
+ blob1 longvarbinary,
+ blob2 longvarbinary,
+ blob3 binary
+);
+
+create table "awful table" (
+ "CuStOmEr iD" int generated by default as identity (start with 57) not null,
+ "first name" varchar(20) default 'Mabel',
+ first_name varchar(20),
+ firstName varchar(20),
+ "last name" varchar(20),
+ E_MAIL varchar(20),
+ _id1 int not null,
+ $id2 int not null,
+ id5_ int not null,
+ id6$ int not null,
+ id7$$ int not null,
+ EmailAddress varchar(30),
+ "from" varchar(30),
+ active bit not null,
+ primary key("CuStOmEr iD")
+);
+
+-- this table should be ignored, nothing generated
+create table BlobsOnly (
+ blob1 longvarbinary,
+ blob2 longvarbinary
+);
+
+create table RegexRename (
+ CUST_ID integer,
+ CUST_NAME varchar(30),
+ CUST_ADDRESS varchar(30),
+ ZIP_CODE char(5),
+ primary key(CUST_ID)
+);
+
+create table AnotherAwfulTable (
+ id int not null,
+ "select" varchar(30),
+ "insert" varchar(30),
+ "update" varchar(30),
+ "delete" varchar(30),
+ primary key(id)
+);
Added:
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/resources/ibatorConfig.xml
URL:
http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/resources/ibatorConfig.xml?rev=833820&view=auto
==============================================================================
---
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/resources/ibatorConfig.xml
(added)
+++
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/main/resources/ibatorConfig.xml
Sun Nov 8 04:08:23 2009
@@ -0,0 +1,186 @@
+<?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>
+ <ibatorContext id="FlatJava5" targetRuntime="Ibatis3"
defaultModelType="flat">
+ <property name="suppressTypeWarnings" value="true" /> <!-- should be
ignored -->
+
+ <ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin"
/>
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator targetPackage="ibatortest.generated.flat.java5.model"
targetProject="generatedsrc">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="ibatortest.generated.flat.java5.xml"
targetProject="generatedsrc">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="MAPPER"
targetPackage="ibatortest.generated.flat.java5.dao"
targetProject="generatedsrc">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" alias="B" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ <table tableName="awful table" alias="A">
+ <property name="useColumnIndexes" value="true"/>
+ <generatedKey column="CuStOmEr iD" sqlStatement="HSQLDB" identity="true"
/>
+ <columnOverride column="first name" property="firstFirstName" />
+ <columnOverride column="first_name" property="secondFirstName" />
+ <columnOverride column="firstName" property="thirdFirstName" />
+ <columnOverride column="from" delimitedColumnName="true" >
+ <property name="fredswife" value="wilma"/>
+ </columnOverride>
+ <columnOverride column="active" javaType="boolean" />
+ </table>
+ </ibatorContext>
+
+ <ibatorContext id="HierarchicalJava5" targetRuntime="Ibatis3"
defaultModelType="hierarchical">
+ <ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin"
/>
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator
targetPackage="ibatortest.generated.hierarchical.java5.model"
targetProject="generatedsrc">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator
targetPackage="ibatortest.generated.hierarchical.java5.xml"
targetProject="generatedsrc">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="MAPPER"
targetPackage="ibatortest.generated.hierarchical.java5.dao"
targetProject="generatedsrc">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" alias="B" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ <table tableName="awful table" alias="A">
+ <property name="useColumnIndexes" value="true"/>
+ <generatedKey column="CuStOmEr iD" sqlStatement="HSQLDB" identity="true"
/>
+ <columnOverride column="first name" property="firstFirstName" />
+ <columnOverride column="first_name" property="secondFirstName" />
+ <columnOverride column="firstName" property="thirdFirstName" />
+ <columnOverride column="from" delimitedColumnName="true" />
+ <columnOverride column="active" javaType="boolean" />
+ </table>
+ </ibatorContext>
+
+ <ibatorContext id="ConditionalJava5" targetRuntime="Ibatis3"
defaultModelType="conditional">
+ <ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin"
/>
+ <ibatorPlugin type="org.apache.ibatis.ibator.plugins.SerializablePlugin" />
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator
targetPackage="ibatortest.generated.conditional.java5.model"
targetProject="generatedsrc">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator
targetPackage="ibatortest.generated.conditional.java5.xml"
targetProject="generatedsrc">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="MAPPER"
targetPackage="ibatortest.generated.conditional.java5.dao"
targetProject="generatedsrc">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" alias="B" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ <table tableName="awful table" alias="A">
+ <property name="useColumnIndexes" value="true"/>
+ <generatedKey column="CuStOmEr iD" sqlStatement="HSQLDB" identity="true"
/>
+ <columnOverride column="first name" property="firstFirstName" />
+ <columnOverride column="first_name" property="secondFirstName" />
+ <columnOverride column="firstName" property="thirdFirstName" />
+ <columnOverride column="from" delimitedColumnName="true" />
+ <columnOverride column="active" javaType="boolean" />
+ </table>
+ </ibatorContext>
+
+ <ibatorContext id="miscellaneousTests" targetRuntime="Ibatis3">
+ <ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin"
/>
+ <ibatorPlugin
type="org.apache.ibatis.ibator.plugins.CaseInsensitiveLikePlugin" />
+ <ibatorPlugin
type="org.apache.ibatis.ibator.plugins.RenameExampleClassPlugin" >
+ <property name="searchString" value="Example$"/>
+ <property name="replaceString" value="Criteria"/>
+ </ibatorPlugin>
+
+ <commentGenerator>
+ <property name="suppressDate" value="true"/>
+ </commentGenerator>
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator
targetPackage="ibatortest.generated.miscellaneous.model"
targetProject="generatedsrc">
+ <property name="trimStrings" value="true" />
+ <property name="rootClass"
value="ibatortest.execute.miscellaneous.BaseClass" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="ibatortest.generated.miscellaneous.xml"
targetProject="generatedsrc">
+ </sqlMapGenerator>
+
+ <daoGenerator type="MAPPER"
targetPackage="ibatortest.generated.miscellaneous.dao"
targetProject="generatedsrc">
+ <property name="rootInterface"
value="ibatortest.execute.miscellaneous.BaseInterface" />
+ <property name="methodNameCalculator" value="EXTENDED"/>
+ </daoGenerator>
+
+ <table tableName="BlobsOnly" /> <!-- should generate a warning -->
+ <table tableName="NonExistantTable" /> <!-- should generate a warning -->
+ <table tableName="PKFields" domainObjectName="MyObject" alias="A" >
+ <ignoreColumn column="fred" /> <!-- should generate a warning -->
+ <ignoreColumn column="decimal30Field" />
+ <columnOverride column="datefield" property="startDate"/>
+ <columnOverride column="decimal155Field" javaType="java.lang.Double" />
+ <columnOverride column="decimal60Field" javaType="int" />
+ <columnOverride column="firstName"
javaType="ibatortest.execute.miscellaneous.FirstName"
+ typeHandler="ibatortest.execute.miscellaneous.FirstNameTypeHandler"/>
+ <columnOverride column="timeField"
javaType="ibatortest.execute.miscellaneous.MyTime"
+ typeHandler="ibatortest.execute.miscellaneous.MyTimeTypeHandler"/>
+ </table>
+ <table tableName="RegexRename">
+ <columnRenamingRule searchString="^CUST" />
+ </table>
+ </ibatorContext>
+
+ <ibatorContext id="miscellaneousTests_NoDAO" targetRuntime="Ibatis3">
+ <property name="autoDelimitKeywords" value="true" />
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator
targetPackage="ibatortest.generated.miscellaneous.model"
targetProject="generatedsrc">
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="ibatortest.generated.miscellaneous.xml"
+ targetProject="generatedsrc"/>
+
+ <table tableName="AnotherAwfulTable" />
+ </ibatorContext>
+</ibatorConfiguration>
Added:
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/AbstractTest.java
URL:
http://svn.apache.org/viewvc/ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/AbstractTest.java?rev=833820&view=auto
==============================================================================
---
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/AbstractTest.java
(added)
+++
ibatis/java/ibator/trunk/core/ibator-systests-ibatis3/src/test/java/ibatortest/AbstractTest.java
Sun Nov 8 04:08:23 2009
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ibatortest;
+
+import java.io.Reader;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Random;
+
+import org.apache.ibatis.io.Resources;
+import org.apache.ibatis.jdbc.ScriptRunner;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.apache.ibatis.session.SqlSessionFactoryBuilder;
+import org.junit.Before;
+
+/**
+ * @author Jeff Butler
+ *
+ */
+public abstract class AbstractTest {
+
+ protected SqlSessionFactory sqlSessionFactory;
+ protected static DateFormat dateOnlyFormat =
SimpleDateFormat.getDateInstance();
+ protected static DateFormat timeOnlyFormat =
SimpleDateFormat.getTimeInstance();
+
+ @Before
+ public void setUp() throws Exception {
+ Connection conn = null;
+
+ try {
+ Class.forName("org.hsqldb.jdbcDriver");
+ conn = DriverManager.getConnection("jdbc:hsqldb:mem:aname", "sa",
+ "");
+
+ Reader reader = Resources.getResourceAsReader("CreateDB.sql");
+
+ ScriptRunner runner = new ScriptRunner(conn);
+ runner.setLogWriter(null);
+ runner.setErrorLogWriter(null);
+ runner.runScript(reader);
+ conn.commit();
+
+ reader.close();
+
+ reader =
Resources.getResourceAsReader("ibatortest/MapperConfig.xml");
+ sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
+ reader.close();
+ } finally {
+ if (conn != null) {
+ conn.close();
+ }
+ }
+ }
+
+ protected byte[] generateRandomBlob() {
+ Random random = new Random(System.currentTimeMillis());
+
+ byte[] answer = new byte[256];
+
+ random.nextBytes(answer);
+
+ return answer;
+ }
+
+ protected boolean blobsAreEqual(byte[] blob1, byte[] blob2) {
+ if (blob1 == null) {
+ return blob2 == null;
+ }
+
+ if (blob2 == null) {
+ return blob1 == null;
+ }
+
+ boolean rc = blob1.length == blob2.length;
+
+ if (rc) {
+ for (int i = 0; i < blob1.length; i++) {
+ if (blob1[i] != blob2[i]) {
+ rc = false;
+ break;
+ }
+ }
+ }
+
+ return rc;
+ }
+
+ protected boolean datesAreEqual(Date date1, Date date2) {
+ if (date1 == null) {
+ return date2 == null;
+ }
+
+ if (date2 == null) {
+ return date1 == null;
+ }
+
+ return
dateOnlyFormat.format(date1).equals(dateOnlyFormat.format(date2));
+
+ }
+
+ protected boolean timesAreEqual(Date date1, Date date2) {
+ if (date1 == null) {
+ return date2 == null;
+ }
+
+ if (date2 == null) {
+ return date1 == null;
+ }
+
+ return
timeOnlyFormat.format(date1).equals(timeOnlyFormat.format(date2));
+
+ }
+}