You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by cb...@apache.org on 2008/08/08 01:21:58 UTC

svn commit: r683745 [19/22] - in /ibatis/trunk/java/ibatis-3: ./ ibatis-3-compat/ ibatis-3-compat/src/ ibatis-3-compat/src/main/ ibatis-3-compat/src/main/java/ ibatis-3-compat/src/main/java/com/ ibatis-3-compat/src/main/java/com/ibatis/ ibatis-3-compat...

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SimpleTypeRegistry.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SimpleTypeRegistry.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SimpleTypeRegistry.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SimpleTypeRegistry.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,64 @@
+package org.apache.ibatis.type;
+
+import java.math.*;
+import java.util.*;
+
+public class SimpleTypeRegistry {
+
+  private static final Set SIMPLE_TYPE_SET = new HashSet();
+
+  static {
+    SIMPLE_TYPE_SET.add(String.class);
+    SIMPLE_TYPE_SET.add(Byte.class);
+    SIMPLE_TYPE_SET.add(Short.class);
+    SIMPLE_TYPE_SET.add(Character.class);
+    SIMPLE_TYPE_SET.add(Integer.class);
+    SIMPLE_TYPE_SET.add(Long.class);
+    SIMPLE_TYPE_SET.add(Float.class);
+    SIMPLE_TYPE_SET.add(Double.class);
+    SIMPLE_TYPE_SET.add(Boolean.class);
+    SIMPLE_TYPE_SET.add(Date.class);
+    SIMPLE_TYPE_SET.add(Class.class);
+    SIMPLE_TYPE_SET.add(BigInteger.class);
+    SIMPLE_TYPE_SET.add(BigDecimal.class);
+
+    SIMPLE_TYPE_SET.add(Collection.class);
+    SIMPLE_TYPE_SET.add(Set.class);
+    SIMPLE_TYPE_SET.add(Map.class);
+    SIMPLE_TYPE_SET.add(List.class);
+    SIMPLE_TYPE_SET.add(HashMap.class);
+    SIMPLE_TYPE_SET.add(TreeMap.class);
+    SIMPLE_TYPE_SET.add(ArrayList.class);
+    SIMPLE_TYPE_SET.add(LinkedList.class);
+    SIMPLE_TYPE_SET.add(HashSet.class);
+    SIMPLE_TYPE_SET.add(TreeSet.class);
+    SIMPLE_TYPE_SET.add(Vector.class);
+    SIMPLE_TYPE_SET.add(Hashtable.class);
+    SIMPLE_TYPE_SET.add(Enumeration.class);
+  }
+
+  /**
+   * Tells us if the class passed in is a knwon common type
+   *
+   * @param clazz The class to check
+   * @return True if the class is known
+   */
+  public static boolean isSimpleType(Class clazz) {
+    if (SIMPLE_TYPE_SET.contains(clazz)) {
+      return true;
+    } else if (Collection.class.isAssignableFrom(clazz)) {
+      return true;
+    } else if (Map.class.isAssignableFrom(clazz)) {
+      return true;
+    } else if (List.class.isAssignableFrom(clazz)) {
+      return true;
+    } else if (Set.class.isAssignableFrom(clazz)) {
+      return true;
+    } else if (Iterator.class.isAssignableFrom(clazz)) {
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlDateTypeHandler.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlDateTypeHandler.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlDateTypeHandler.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlDateTypeHandler.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,22 @@
+package org.apache.ibatis.type;
+
+import java.sql.*;
+
+public class SqlDateTypeHandler extends BaseTypeHandler {
+
+  public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType)
+      throws SQLException {
+    ps.setDate(i, (java.sql.Date) parameter);
+  }
+
+  public Object getNullableResult(ResultSet rs, String columnName)
+      throws SQLException {
+    return rs.getDate(columnName);
+  }
+
+  public Object getNullableResult(CallableStatement cs, int columnIndex)
+      throws SQLException {
+    return cs.getDate(columnIndex);
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlTimeTypeHandler.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlTimeTypeHandler.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlTimeTypeHandler.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlTimeTypeHandler.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,22 @@
+package org.apache.ibatis.type;
+
+import java.sql.*;
+
+public class SqlTimeTypeHandler extends BaseTypeHandler {
+
+  public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType)
+      throws SQLException {
+    ps.setTime(i, (java.sql.Time) parameter);
+  }
+
+  public Object getNullableResult(ResultSet rs, String columnName)
+      throws SQLException {
+    return rs.getTime(columnName);
+  }
+
+  public Object getNullableResult(CallableStatement cs, int columnIndex)
+      throws SQLException {
+    return cs.getTime(columnIndex);
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlTimestampTypeHandler.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlTimestampTypeHandler.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlTimestampTypeHandler.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/SqlTimestampTypeHandler.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,22 @@
+package org.apache.ibatis.type;
+
+import java.sql.*;
+
+public class SqlTimestampTypeHandler extends BaseTypeHandler {
+
+  public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType)
+      throws SQLException {
+    ps.setTimestamp(i, (java.sql.Timestamp) parameter);
+  }
+
+  public Object getNullableResult(ResultSet rs, String columnName)
+      throws SQLException {
+    return rs.getTimestamp(columnName);
+  }
+
+  public Object getNullableResult(CallableStatement cs, int columnIndex)
+      throws SQLException {
+    return cs.getTimestamp(columnIndex);
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/StringTypeHandler.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/StringTypeHandler.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/StringTypeHandler.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/StringTypeHandler.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,22 @@
+package org.apache.ibatis.type;
+
+import java.sql.*;
+
+public class StringTypeHandler extends BaseTypeHandler {
+
+  public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType)
+      throws SQLException {
+    ps.setString(i, ((String) parameter));
+  }
+
+  public Object getNullableResult(ResultSet rs, String columnName)
+      throws SQLException {
+    return rs.getString(columnName);
+  }
+
+  public Object getNullableResult(CallableStatement cs, int columnIndex)
+      throws SQLException {
+    return cs.getString(columnIndex);
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TimeOnlyTypeHandler.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TimeOnlyTypeHandler.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TimeOnlyTypeHandler.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TimeOnlyTypeHandler.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,31 @@
+package org.apache.ibatis.type;
+
+import java.sql.*;
+import java.util.Date;
+
+public class TimeOnlyTypeHandler extends BaseTypeHandler {
+
+  public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType)
+      throws SQLException {
+    ps.setTime(i, new java.sql.Time(((Date) parameter).getTime()));
+  }
+
+  public Object getNullableResult(ResultSet rs, String columnName)
+      throws SQLException {
+    java.sql.Time sqlTime = rs.getTime(columnName);
+    if (sqlTime != null) {
+      return new java.util.Date(sqlTime.getTime());
+    }
+    return null;
+  }
+
+  public Object getNullableResult(CallableStatement cs, int columnIndex)
+      throws SQLException {
+    java.sql.Time sqlTime = cs.getTime(columnIndex);
+    if (sqlTime != null) {
+      return new java.util.Date(sqlTime.getTime());
+    }
+    return null;
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeAliasRegistry.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeAliasRegistry.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeAliasRegistry.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeAliasRegistry.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,51 @@
+package org.apache.ibatis.type;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+public class TypeAliasRegistry {
+
+  private final HashMap<String, String> TYPE_ALIASES = new HashMap<String, String>();
+
+  public TypeAliasRegistry() {
+    registerAlias("string", String.class.getName());
+    registerAlias("byte", Byte.class.getName());
+    registerAlias("long", Long.class.getName());
+    registerAlias("short", Short.class.getName());
+    registerAlias("int", Integer.class.getName());
+    registerAlias("integer", Integer.class.getName());
+    registerAlias("double", Double.class.getName());
+    registerAlias("float", Float.class.getName());
+    registerAlias("boolean", Boolean.class.getName());
+    registerAlias("date", Date.class.getName());
+    registerAlias("decimal", BigDecimal.class.getName());
+    registerAlias("bigdecimal", BigDecimal.class.getName());
+    registerAlias("object", Object.class.getName());
+    registerAlias("map", Map.class.getName());
+    registerAlias("hashmap", HashMap.class.getName());
+    registerAlias("list", List.class.getName());
+    registerAlias("arraylist", ArrayList.class.getName());
+    registerAlias("collection", Collection.class.getName());
+    registerAlias("iterator", Iterator.class.getName());
+  }
+
+  public String resolveAlias(String string) {
+    if (string == null) return null;
+    String key = string.toLowerCase();
+    String value = string;
+    if (TYPE_ALIASES.containsKey(key)) {
+      value = TYPE_ALIASES.get(key);
+    }
+    return value;
+  }
+
+  public void registerAlias(String alias, String value) {
+    assert alias != null;
+    String key = alias.toLowerCase();
+    if (TYPE_ALIASES.containsKey(key) && !TYPE_ALIASES.get(key).equals(value)) {
+      throw new RuntimeException("The alias '" + key + "' is already mapped to the value '" + TYPE_ALIASES.get(alias) + "'.");
+    }
+    TYPE_ALIASES.put(key, value);
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeHandler.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeHandler.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeHandler.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeHandler.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,16 @@
+package org.apache.ibatis.type;
+
+import java.sql.*;
+
+public interface TypeHandler {
+
+  public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType)
+      throws SQLException;
+
+  public Object getResult(ResultSet rs, String columnName)
+      throws SQLException;
+
+  public Object getResult(CallableStatement cs, int columnIndex)
+      throws SQLException;
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeHandlerRegistry.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeHandlerRegistry.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeHandlerRegistry.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/TypeHandlerRegistry.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,114 @@
+package org.apache.ibatis.type;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+public class TypeHandlerRegistry {
+
+  private static final Map<Class, Class> reversePrimitiveMap = new HashMap<Class, Class>() {
+    {
+      put(Byte.class, byte.class);
+      put(Short.class, short.class);
+      put(Integer.class, int.class);
+      put(Long.class, long.class);
+      put(Float.class, float.class);
+      put(Double.class, double.class);
+      put(Boolean.class, boolean.class);
+    }
+  };
+
+  private final Map<Class, Map<JdbcType, TypeHandler>> TYPE_HANDLER_MAP = new HashMap<Class, Map<JdbcType, TypeHandler>>();
+  private final TypeHandler UNKNOWN_TYPE_HANDLER = new UnknownTypeHandler(this);
+
+  public TypeHandlerRegistry() {
+    register(Boolean.class, new BooleanTypeHandler());
+    register(boolean.class, new BooleanTypeHandler());
+
+    register(Byte.class, new ByteTypeHandler());
+    register(byte.class, new ByteTypeHandler());
+
+    register(Short.class, new ShortTypeHandler());
+    register(short.class, new ShortTypeHandler());
+
+    register(Integer.class, new IntegerTypeHandler());
+    register(int.class, new IntegerTypeHandler());
+
+    register(Long.class, new LongTypeHandler());
+    register(long.class, new LongTypeHandler());
+
+    register(Float.class, new FloatTypeHandler());
+    register(float.class, new FloatTypeHandler());
+
+    register(Double.class, new DoubleTypeHandler());
+    register(double.class, new DoubleTypeHandler());
+
+    register(String.class, new StringTypeHandler());
+    register(String.class, JdbcType.CLOB, new ClobTypeHandler());
+    register(String.class, JdbcType.LONGVARCHAR, new ClobTypeHandler());
+
+    register(BigDecimal.class, new BigDecimalTypeHandler());
+
+    register(byte[].class, new ByteArrayTypeHandler());
+    register(byte[].class, JdbcType.BLOB, new BlobTypeHandler());
+    register(byte[].class, JdbcType.LONGVARBINARY, new BlobTypeHandler());
+
+    register(Object.class, new ObjectTypeHandler());
+    register(Object.class, JdbcType.OTHER, new ObjectTypeHandler());
+
+    register(Date.class, new DateTypeHandler());
+    register(Date.class, JdbcType.DATE, new DateOnlyTypeHandler());
+    register(Date.class, JdbcType.TIME, new TimeOnlyTypeHandler());
+
+    register(java.sql.Date.class, new SqlDateTypeHandler());
+    register(java.sql.Time.class, new SqlTimeTypeHandler());
+    register(java.sql.Timestamp.class, new SqlTimestampTypeHandler());
+  }
+
+  public boolean hasTypeHandler(Class javaType) {
+    return hasTypeHandler(javaType, null);
+  }
+
+  public boolean hasTypeHandler(Class javaType, JdbcType jdbcType) {
+    return javaType != null && getTypeHandler(javaType, jdbcType) != null;
+  }
+
+  public TypeHandler getTypeHandler(Class type) {
+    return getTypeHandler(type, null);
+  }
+
+  public TypeHandler getTypeHandler(Class type, JdbcType jdbcType) {
+    Map jdbcHandlerMap = TYPE_HANDLER_MAP.get(type);
+    TypeHandler handler = null;
+    if (jdbcHandlerMap != null) {
+      handler = (TypeHandler) jdbcHandlerMap.get(jdbcType);
+      if (handler == null) {
+        handler = (TypeHandler) jdbcHandlerMap.get(null);
+      }
+    }
+    if (handler == null && type != null && Enum.class.isAssignableFrom(type)) {
+      handler = new EnumTypeHandler(type);
+    }
+    return handler;
+  }
+
+  public TypeHandler getUnkownTypeHandler() {
+    return UNKNOWN_TYPE_HANDLER;
+  }
+
+  public void register(Class type, TypeHandler handler) {
+    register(type, null, handler);
+  }
+
+  public void register(Class type, JdbcType jdbcType, TypeHandler handler) {
+    Map<JdbcType, TypeHandler> map = TYPE_HANDLER_MAP.get(type);
+    if (map == null) {
+      map = new HashMap<JdbcType, TypeHandler>();
+      TYPE_HANDLER_MAP.put(type, map);
+    }
+    map.put(jdbcType, handler);
+    if (reversePrimitiveMap.containsKey(type)) {
+      register(reversePrimitiveMap.get(type), jdbcType, handler);
+    }
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/UnknownTypeHandler.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/UnknownTypeHandler.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/UnknownTypeHandler.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/type/UnknownTypeHandler.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,39 @@
+package org.apache.ibatis.type;
+
+import java.sql.*;
+
+public class UnknownTypeHandler extends BaseTypeHandler {
+
+  private TypeHandlerRegistry typeHandlerRegistry;
+
+  public UnknownTypeHandler(TypeHandlerRegistry typeHandlerRegistry) {
+    this.typeHandlerRegistry = typeHandlerRegistry;
+  }
+
+  public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType)
+      throws SQLException {
+    TypeHandler handler = resolveTypeHandler(parameter, jdbcType);
+    handler.setParameter(ps, i, parameter, jdbcType);
+  }
+
+  public Object getNullableResult(ResultSet rs, String columnName)
+      throws SQLException {
+    return rs.getObject(columnName);
+  }
+
+  public Object getNullableResult(CallableStatement cs, int columnIndex)
+      throws SQLException {
+    return cs.getObject(columnIndex);
+  }
+
+  private TypeHandler resolveTypeHandler(Object parameter, JdbcType jdbcType) {
+    TypeHandler handler;
+    if (parameter == null) {
+      handler = typeHandlerRegistry.getTypeHandler(Object.class);
+    } else {
+      handler = typeHandlerRegistry.getTypeHandler(parameter.getClass(), jdbcType);
+    }
+    return handler;
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/Nodelet.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/Nodelet.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/Nodelet.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/Nodelet.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,9 @@
+package org.apache.ibatis.xml;
+
+import java.lang.annotation.*;
+
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Nodelet {
+  String value();
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletContext.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletContext.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletContext.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletContext.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,237 @@
+package org.apache.ibatis.xml;
+
+import org.w3c.dom.*;
+
+import java.util.Properties;
+
+public class NodeletContext {
+
+  private Node node;
+  private String body;
+  private Properties attributes;
+  private Properties variables;
+
+  public NodeletContext(Node node, Properties variables) {
+    this.node = node;
+    this.variables = variables;
+    this.attributes = parseAttributes(node);
+    this.body = parseBody(node);
+  }
+
+  public Node getNode() {
+    return node;
+  }
+
+  public String getStringBody() {
+    return getStringBody(null);
+  }
+
+  public String getStringBody(String def) {
+    if (body == null) {
+      return def;
+    } else {
+      return body;
+    }
+  }
+
+  public Boolean getBooleanBody() {
+    return getBooleanBody(null);
+  }
+
+  public Boolean getBooleanBody(Boolean def) {
+    if (body == null) {
+      return def;
+    } else {
+      return Boolean.valueOf(body);
+    }
+  }
+
+  public Integer getIntBody() {
+    return getIntBody(null);
+  }
+
+  public Integer getIntBody(Integer def) {
+    if (body == null) {
+      return def;
+    } else {
+      return Integer.parseInt(body);
+    }
+  }
+
+  public Long getLongBody() {
+    return getLongBody(null);
+  }
+
+  public Long getLongBody(Long def) {
+    if (body == null) {
+      return def;
+    } else {
+      return Long.parseLong(body);
+    }
+  }
+
+  public Double getDoubleBody() {
+    return getDoubleBody(null);
+  }
+
+  public Double getDoubleBody(Double def) {
+    if (body == null) {
+      return def;
+    } else {
+      return Double.parseDouble(body);
+    }
+  }
+
+  public Float getFloatBody() {
+    return getFloatBody(null);
+  }
+
+  public Float getFloatBody(Float def) {
+    if (body == null) {
+      return def;
+    } else {
+      return Float.parseFloat(body);
+    }
+  }
+
+  public String getStringAttribute(String name) {
+    return getStringAttribute(name, null);
+  }
+
+  public String getStringAttribute(String name, String def) {
+    String value = attributes.getProperty(name);
+    if (value == null) {
+      return def;
+    } else {
+      return value;
+    }
+  }
+
+  public Boolean getBooleanAttribute(String name) {
+    return getBooleanAttribute(name, null);
+  }
+
+  public Boolean getBooleanAttribute(String name, Boolean def) {
+    String value = attributes.getProperty(name);
+    if (value == null) {
+      return def;
+    } else {
+      return Boolean.valueOf(value);
+    }
+  }
+
+  public Integer getIntAttribute(String name) {
+    return getIntAttribute(name, null);
+  }
+
+  public Integer getIntAttribute(String name, Integer def) {
+    String value = attributes.getProperty(name);
+    if (value == null) {
+      return def;
+    } else {
+      return Integer.parseInt(value);
+    }
+  }
+
+  public Long getLongAttribute(String name) {
+    return getLongAttribute(name, null);
+  }
+
+  public Long getLongAttribute(String name, Long def) {
+    String value = attributes.getProperty(name);
+    if (value == null) {
+      return def;
+    } else {
+      return Long.parseLong(value);
+    }
+  }
+
+  public Double getDoubleAttribute(String name) {
+    return getDoubleAttribute(name, null);
+  }
+
+  public Double getDoubleAttribute(String name, Double def) {
+    String value = attributes.getProperty(name);
+    if (value == null) {
+      return def;
+    } else {
+      return Double.parseDouble(value);
+    }
+  }
+
+  public Float getFloatAttribute(String name) {
+    return getFloatAttribute(name, null);
+  }
+
+  public Float getFloatAttribute(String name, Float def) {
+    String value = attributes.getProperty(name);
+    if (value == null) {
+      return def;
+    } else {
+      return Float.parseFloat(value);
+    }
+  }
+
+  private Properties parseAttributes(Node n) {
+    Properties attributes = new Properties();
+    NamedNodeMap attributeNodes = n.getAttributes();
+    if (attributeNodes != null) {
+      for (int i = 0; i < attributeNodes.getLength(); i++) {
+        Node attribute = attributeNodes.item(i);
+        String value = parsePropertyTokens(attribute.getNodeValue());
+        attributes.put(attribute.getNodeName(), value);
+      }
+    }
+    return attributes;
+  }
+
+  private String parsePropertyTokens(String string) {
+    final String OPEN = "${";
+    final String CLOSE = "}";
+
+    String newString = string;
+    if (newString != null && variables != null) {
+      int start = newString.indexOf(OPEN);
+      int end = newString.indexOf(CLOSE);
+
+      while (start > -1 && end > start) {
+        String prepend = newString.substring(0, start);
+        String append = newString.substring(end + CLOSE.length());
+        String propName = newString.substring(start + OPEN.length(), end);
+        String propValue = variables.getProperty(propName);
+        if (propValue == null) {
+          newString = prepend + propName + append;
+        } else {
+          newString = prepend + propValue + append;
+        }
+        start = newString.indexOf(OPEN);
+        end = newString.indexOf(CLOSE);
+      }
+    }
+    return newString;
+  }
+
+  private String parseBody(Node node) {
+    String data = getBodyData(node);
+    if (data == null) {
+      NodeList children = node.getChildNodes();
+      for (int i = 0; i < children.getLength(); i++) {
+        Node child = children.item(i);
+        data = getBodyData(child);
+        if (data != null) break;
+      }
+    }
+    return data;
+  }
+
+  private String getBodyData(Node child) {
+    if (child.getNodeType() == Node.CDATA_SECTION_NODE
+        || child.getNodeType() == Node.TEXT_NODE) {
+      String data = ((CharacterData) child).getData();
+      data = parsePropertyTokens(data);
+      return data;
+    }
+    return null;
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletException.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletException.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletException.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletException.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,19 @@
+package org.apache.ibatis.xml;
+
+public class NodeletException extends RuntimeException {
+  public NodeletException() {
+    super();
+  }
+
+  public NodeletException(String message) {
+    super(message);
+  }
+
+  public NodeletException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public NodeletException(Throwable cause) {
+    super(cause);
+  }
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletParser.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletParser.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletParser.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletParser.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,187 @@
+package org.apache.ibatis.xml;
+
+import org.w3c.dom.*;
+import org.xml.sax.*;
+
+import javax.xml.parsers.*;
+import java.io.*;
+import java.lang.reflect.Method;
+import java.util.*;
+
+public class NodeletParser {
+
+  private Map nodeletMap = new HashMap();
+
+  private boolean validation;
+  private EntityResolver entityResolver;
+  private Properties variables;
+
+  public NodeletParser() {
+    setValidation(false);
+    setVariables(new Properties());
+    setEntityResolver(null);
+  }
+
+  /**
+   * Registers a nodelet for the specified XPath.  Current XPaths supported
+   * are:
+   * <ul>
+   * <li> Element Path - /rootElement/childElement/theElement
+   * <li> Closing element - /rootElement/childElement/end()
+   * <li> All Elements Named - //theElement
+   * </ul>
+   */
+  public void addNodeletHandler(Object handler) {
+    Class type = handler.getClass();
+    Method[] methods = type.getMethods();
+    for (Method m : methods) {
+      Nodelet n = m.getAnnotation(Nodelet.class);
+      if (n != null) {
+        checkMethodApplicable(n, type, m);
+        nodeletMap.put(n.value(), new NodeletWrapper(handler, m));
+      }
+    }
+  }
+
+  /**
+   * Begins parsing from the provided Reader.
+   */
+  public void parse(Reader reader) throws NodeletException {
+    try {
+      Document doc = createDocument(reader);
+      parse(doc.getLastChild());
+    } catch (Exception e) {
+      throw new NodeletException("Error parsing XML.  Cause: " + e, e);
+    }
+  }
+
+  public void setVariables(Properties variables) {
+    this.variables = variables;
+  }
+
+  public void setValidation(boolean validation) {
+    this.validation = validation;
+  }
+
+  public void setEntityResolver(EntityResolver resolver) {
+    this.entityResolver = resolver;
+  }
+
+  private void checkMethodApplicable(Nodelet n, Class type, Method m) {
+    if (nodeletMap.containsKey(n.value())) {
+      throw new NodeletException("This nodelet parser already has a handler for path " + n.value());
+    }
+    Class<?>[] params = m.getParameterTypes();
+    if (params.length != 1 || params[0] != NodeletContext.class) {
+      throw new NodeletException("The method " + m.getName() + " on " + type + " does not take a single parameter of type NodeletContext.");
+    }
+  }
+
+  /**
+   * Begins parsing from the provided Node.
+   */
+  private void parse(Node node) {
+    Path path = new Path();
+    processNodelet(node, "/");
+    process(node, path);
+  }
+
+  /**
+   * A recursive method that walkes the DOM tree, registers XPaths and
+   * calls Nodelets registered under those XPaths.
+   */
+  private void process(Node node, Path path) {
+    if (node instanceof Element) {
+      // Element
+      String elementName = node.getNodeName();
+      path.add(elementName);
+      processNodelet(node, path.toString());
+      processNodelet(node, new StringBuffer("//").append(elementName).toString());
+
+      // Children
+      NodeList children = node.getChildNodes();
+      for (int i = 0; i < children.getLength(); i++) {
+        process(children.item(i), path);
+      }
+      path.add("end()");
+      processNodelet(node, path.toString());
+      path.remove();
+      path.remove();
+    }
+  }
+
+  private void processNodelet(Node node, String pathString) {
+    NodeletWrapper nodelet = (NodeletWrapper) nodeletMap.get(pathString);
+    if (nodelet != null) {
+      try {
+        nodelet.process(new NodeletContext(node, variables));
+      } catch (Exception e) {
+        throw new NodeletException("Error parsing XPath '" + pathString + "'.  Cause: " + e, e);
+      }
+    }
+  }
+
+  /**
+   * Creates a JAXP Document from a reader.
+   */
+  private Document createDocument(Reader reader) throws ParserConfigurationException, FactoryConfigurationError, SAXException, IOException {
+    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+    factory.setValidating(validation);
+
+    factory.setNamespaceAware(false);
+    factory.setIgnoringComments(true);
+    factory.setIgnoringElementContentWhitespace(false);
+    factory.setCoalescing(false);
+    factory.setExpandEntityReferences(true);
+
+    DocumentBuilder builder = factory.newDocumentBuilder();
+    builder.setEntityResolver(entityResolver);
+    builder.setErrorHandler(new ErrorHandler() {
+      public void error(SAXParseException exception) throws SAXException {
+        throw exception;
+      }
+
+      public void fatalError(SAXParseException exception) throws SAXException {
+        throw exception;
+      }
+
+      public void warning(SAXParseException exception) throws SAXException {
+      }
+    });
+
+    return builder.parse(new InputSource(reader));
+  }
+
+  /**
+   * Inner helper class that assists with building XPath paths.
+   * <p/>
+   * Note:  Currently this is a bit slow and could be optimized.
+   */
+  private static class Path {
+
+    private List nodeList = new ArrayList();
+
+    public Path() {
+    }
+
+    public void add(String node) {
+      nodeList.add(node);
+    }
+
+    public void remove() {
+      nodeList.remove(nodeList.size() - 1);
+    }
+
+    public String toString() {
+      StringBuffer buffer = new StringBuffer("/");
+      for (int i = 0; i < nodeList.size(); i++) {
+        buffer.append(nodeList.get(i));
+        if (i < nodeList.size() - 1) {
+          buffer.append("/");
+        }
+      }
+      return buffer.toString();
+    }
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletWrapper.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletWrapper.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletWrapper.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/xml/NodeletWrapper.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,23 @@
+package org.apache.ibatis.xml;
+
+import java.lang.reflect.Method;
+
+public class NodeletWrapper {
+
+  private Object nodeletTarget;
+  private Method method;
+
+  public NodeletWrapper(Object nodeletTarget, Method method) {
+    this.nodeletTarget = nodeletTarget;
+    this.method = method;
+  }
+
+  public void process(NodeletContext context) {
+    try {
+      method.invoke(nodeletTarget, new Object[]{context});
+    } catch (Exception e) {
+      throw new NodeletException("Error processing node " + context.getNode().getNodeName() + ". Cause: " + e, e);
+    }
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/StoredProcedures.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/StoredProcedures.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/StoredProcedures.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/StoredProcedures.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,45 @@
+package databases.blog;
+
+import java.sql.*;
+
+public class StoredProcedures {
+  public static void selectTwoSetsOfTwoAuthors(int p1, int p2, ResultSet[] rs1, ResultSet[] rs2) throws SQLException {
+    Connection conn = DriverManager.getConnection("jdbc:default:connection");
+    PreparedStatement ps1 = conn.prepareStatement("select * from author where id in (?,?)");
+    ps1.setInt(1, p1);
+    ps1.setInt(2, p2);
+    rs1[0] = ps1.executeQuery();
+    PreparedStatement ps2 = conn.prepareStatement("select * from author where id in (?,?)");
+    ps2.setInt(1, p2);
+    ps2.setInt(2, p1);
+    rs2[0] = ps2.executeQuery();
+    conn.close();
+  }
+
+  public static void insertAuthor(int id, String username, String password, String email) throws SQLException {
+    Connection conn = DriverManager.getConnection("jdbc:default:connection");
+    try {
+      PreparedStatement ps = conn.prepareStatement("INSERT INTO author (id, username, password, email) VALUES (?,?,?,?)");
+      ps.setInt(1, id);
+      ps.setString(2, username);
+      ps.setString(3, password);
+      ps.setString(4, email);
+      ps.executeUpdate();
+    } finally {
+      conn.close();
+    }
+  }
+
+  public static void selectAuthorViaOutParams(int id, String[] username, String[] password, String[] email, String[] bio) throws SQLException {
+    Connection conn = DriverManager.getConnection("jdbc:default:connection");
+    PreparedStatement ps = conn.prepareStatement("select * from author where id = ?");
+    ps.setInt(1, id);
+    ResultSet rs = ps.executeQuery();
+    rs.next();
+    username[0] = rs.getString("username");
+    password[0] = rs.getString("password");
+    email[0] = rs.getString("email");
+    bio[0] = rs.getString("bio");
+    conn.close();
+  }
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby-dataload.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby-dataload.sql?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby-dataload.sql (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby-dataload.sql Thu Aug  7 16:21:46 2008
@@ -0,0 +1,28 @@
+INSERT INTO author (id,username, password, email, bio, favourite_section) VALUES (101,'jim','********','jim@ibatis.apache.org','','NEWS');
+INSERT INTO author (id,username, password, email, bio, favourite_section) VALUES (102,'sally','********','sally@ibatis.apache.org',null,'VIDEOS');
+
+INSERT INTO blog (id,author_id,title) VALUES (1,101,'Jim Business');
+INSERT INTO blog (id,author_id,title) VALUES (2,102,'Bally Slog');
+
+INSERT INTO post (id,blog_id,author_id,created_on,section,subject,body) VALUES (1,1,101,'2007-12-05-00.00.00','NEWS','Corn nuts','I think if I never smelled another corn nut it would be too soon...');
+INSERT INTO post (id,blog_id,author_id,created_on,section,subject,body) VALUES (2,1,101,'2008-01-12-00.00.00','VIDEOS','Paul Hogan on Toy Dogs','That''s not a dog.  THAT''s a dog!');
+INSERT INTO post (id,blog_id,author_id,created_on,section,subject,body) VALUES (3,2,102,'2007-12-05-00.00.00','PODCASTS','Monster Trucks','I think monster trucks are great...');
+INSERT INTO post (id,blog_id,author_id,created_on,section,subject,body) VALUES (4,2,102,'2008-01-12-00.00.00','IMAGES','Tea Parties','A tea party is no place to hold a business meeting...');
+
+--BAD POST
+INSERT INTO post (id,blog_id,author_id,created_on,section,subject,body) VALUES (5,null,101,'2008-01-12-00.00.00','IMAGES','An orphaned post','this post is orphaned');
+
+INSERT INTO tag (id,name) VALUES (1,'funny');
+INSERT INTO tag (id,name) VALUES (2,'cool');
+INSERT INTO tag (id,name) VALUES (3,'food');
+
+INSERT INTO post_tag (post_id,tag_id) VALUES (1,1);
+INSERT INTO post_tag (post_id,tag_id) VALUES (1,2);
+INSERT INTO post_tag (post_id,tag_id) VALUES (1,3);
+INSERT INTO post_tag (post_id,tag_id) VALUES (2,1);
+INSERT INTO post_tag (post_id,tag_id) VALUES (4,3);
+
+INSERT INTO comment (id,post_id,name,comment) VALUES (1,1,'troll','I disagree and think...');
+INSERT INTO comment (id,post_id,name,comment) VALUES (2,1,'anonymous','I agree and think troll is an...');
+INSERT INTO comment (id,post_id,name,comment) VALUES (3,3,'rider','I prefer motorcycles to monster trucks...');
+

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby-schema.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby-schema.sql?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby-schema.sql (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby-schema.sql Thu Aug  7 16:21:46 2008
@@ -0,0 +1,75 @@
+DROP TABLE comment;
+DROP TABLE post_tag;
+DROP TABLE tag;
+DROP TABLE post;
+DROP TABLE blog;
+DROP TABLE author;
+DROP PROCEDURE selectTwoSetsOfAuthors;
+DROP PROCEDURE insertAuthor;
+DROP PROCEDURE selectAuthorViaOutParams;
+
+CREATE TABLE author (
+  id                INT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
+  username          VARCHAR(255) NOT NULL,
+  password          VARCHAR(255) NOT NULL,
+  email             VARCHAR(255) NOT NULL,
+  bio               LONG VARCHAR,
+  favourite_section VARCHAR(25),
+  PRIMARY KEY (id)
+);
+
+CREATE TABLE blog (
+  id          INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+  author_id   INT NOT NULL,
+  title       VARCHAR(255),
+  PRIMARY KEY (id)
+);
+
+CREATE TABLE post (
+  id          INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+  blog_id     INT,
+  author_id   INT NOT NULL,
+  created_on  TIMESTAMP NOT NULL,
+  section     VARCHAR(25) NOT NULL,
+  subject     VARCHAR(255) NOT NULL,
+  body        CLOB NOT NULL,
+  PRIMARY KEY (id),
+  FOREIGN KEY (blog_id) REFERENCES blog(id)
+);
+
+CREATE TABLE tag (
+  id          INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+  name        VARCHAR(255) NOT NULL,
+  PRIMARY KEY (id)
+);
+
+CREATE TABLE post_tag (
+  post_id     INT NOT NULL,
+  tag_id      INT NOT NULL,
+  PRIMARY KEY (post_id, tag_id)
+);
+
+CREATE TABLE comment (
+  id          INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+  post_id     INT NOT NULL,
+  name        LONG VARCHAR NOT NULL,
+  comment     LONG VARCHAR NOT NULL,
+  PRIMARY KEY (id)
+);
+
+CREATE PROCEDURE selectTwoSetsOfAuthors(DP1 INTEGER, DP2 INTEGER)
+PARAMETER STYLE JAVA
+LANGUAGE JAVA
+READS SQL DATA
+DYNAMIC RESULT SETS 2
+EXTERNAL NAME 'databases.blog.StoredProcedures.selectTwoSetsOfTwoAuthors';
+
+CREATE PROCEDURE insertAuthor(DP1 INTEGER, DP2 VARCHAR(255), DP3 VARCHAR(255), DP4 VARCHAR(255))
+PARAMETER STYLE JAVA
+LANGUAGE JAVA
+EXTERNAL NAME 'databases.blog.StoredProcedures.insertAuthor';
+
+CREATE PROCEDURE selectAuthorViaOutParams(ID INTEGER, OUT USERNAME VARCHAR(255), OUT PASSWORD VARCHAR(255), OUT EMAIL VARCHAR(255), OUT BIO VARCHAR(255))
+PARAMETER STYLE JAVA
+LANGUAGE JAVA
+EXTERNAL NAME 'databases.blog.StoredProcedures.selectAuthorViaOutParams';

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby.properties?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby.properties (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/blog/blog-derby.properties Thu Aug  7 16:21:46 2008
@@ -0,0 +1,4 @@
+driver=org.apache.derby.jdbc.EmbeddedDriver
+url=jdbc:derby:ibderby;create=true
+username=
+password=
\ No newline at end of file

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb-dataload.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb-dataload.sql?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb-dataload.sql (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb-dataload.sql Thu Aug  7 16:21:46 2008
@@ -0,0 +1,102 @@
+INSERT INTO sequence VALUES('ordernum', 1000);
+
+INSERT INTO signon VALUES('j2ee','j2ee');
+INSERT INTO signon VALUES('ACID','ACID');
+
+INSERT INTO account VALUES('j2ee','yourname@yourdomain.com','ABC', 'XYX', 'OK', '901 San Antonio Road', 'MS UCUP02-206', 'Palo Alto', 'CA', '94303', 'USA',  '555-555-5555');
+INSERT INTO account VALUES('ACID','acid@yourdomain.com','ABC', 'XYX', 'OK', '901 San Antonio Road', 'MS UCUP02-206', 'Palo Alto', 'CA', '94303', 'USA',  '555-555-5555');
+
+INSERT INTO profile VALUES('j2ee','english','DOGS',1,1);
+INSERT INTO profile VALUES('ACID','english','CATS',1,1);
+
+INSERT INTO bannerdata VALUES ('FISH','<image src="../images/banner_fish.gif">');
+INSERT INTO bannerdata VALUES ('CATS','<image src="../images/banner_cats.gif">');
+INSERT INTO bannerdata VALUES ('DOGS','<image src="../images/banner_dogs.gif">');
+INSERT INTO bannerdata VALUES ('REPTILES','<image src="../images/banner_reptiles.gif">');
+INSERT INTO bannerdata VALUES ('BIRDS','<image src="../images/banner_birds.gif">');
+
+INSERT INTO category VALUES ('FISH','Fish','<image src="../images/fish_icon.gif"><font size="5" color="blue"> Fish</font>');
+INSERT INTO category VALUES ('DOGS','Dogs','<image src="../images/dogs_icon.gif"><font size="5" color="blue"> Dogs</font>');
+INSERT INTO category VALUES ('REPTILES','Reptiles','<image src="../images/reptiles_icon.gif"><font size="5" color="blue"> Reptiles</font>');
+INSERT INTO category VALUES ('CATS','Cats','<image src="../images/cats_icon.gif"><font size="5" color="blue"> Cats</font>');
+INSERT INTO category VALUES ('BIRDS','Birds','<image src="../images/birds_icon.gif"><font size="5" color="blue"> Birds</font>');
+
+INSERT INTO product VALUES ('FI-SW-01','FISH','Angelfish','<image src="../images/fish1.gif">Salt Water fish from Australia');
+INSERT INTO product VALUES ('FI-SW-02','FISH','Tiger Shark','<image src="../images/fish4.gif">Salt Water fish from Australia');
+INSERT INTO product VALUES ('FI-FW-01','FISH', 'Koi','<image src="../images/fish3.gif">Fresh Water fish from Japan');
+INSERT INTO product VALUES ('FI-FW-02','FISH', 'Goldfish','<image src="../images/fish2.gif">Fresh Water fish from China');
+INSERT INTO product VALUES ('K9-BD-01','DOGS','Bulldog','<image src="../images/dog2.gif">Friendly dog from England');
+INSERT INTO product VALUES ('K9-PO-02','DOGS','Poodle','<image src="../images/dog6.gif">Cute dog from France');
+INSERT INTO product VALUES ('K9-DL-01','DOGS', 'Dalmation','<image src="../images/dog5.gif">Great dog for a Fire Station');
+INSERT INTO product VALUES ('K9-RT-01','DOGS', 'Golden Retriever','<image src="../images/dog1.gif">Great family dog');
+INSERT INTO product VALUES ('K9-RT-02','DOGS', 'Labrador Retriever','<image src="../images/dog5.gif">Great hunting dog');
+INSERT INTO product VALUES ('K9-CW-01','DOGS', 'Chihuahua','<image src="../images/dog4.gif">Great companion dog');
+INSERT INTO product VALUES ('RP-SN-01','REPTILES','Rattlesnake','<image src="../images/snake1.gif">Doubles as a watch dog');
+INSERT INTO product VALUES ('RP-LI-02','REPTILES','Iguana','<image src="../images/lizard1.gif">Friendly green friend');
+INSERT INTO product VALUES ('FL-DSH-01','CATS','Manx','<image src="../images/cat2.gif">Great for reducing mouse populations');
+INSERT INTO product VALUES ('FL-DLH-02','CATS','Persian','<image src="../images/cat1.gif">Friendly house cat, doubles as a princess');
+INSERT INTO product VALUES ('AV-CB-01','BIRDS','Amazon Parrot','<image src="../images/bird2.gif">Great companion for up to 75 years');
+INSERT INTO product VALUES ('AV-SB-02','BIRDS','Finch','<image src="../images/bird1.gif">Great stress reliever');
+
+INSERT INTO supplier VALUES (1,'XYZ Pets','AC','600 Avon Way','','Los Angeles','CA','94024','212-947-0797');
+INSERT INTO supplier VALUES (2,'ABC Pets','AC','700 Abalone Way','','San Francisco ','CA','94024','415-947-0797');
+
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-1','FI-SW-01',16.50,10.00,1,'P','Large');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-2','FI-SW-01',16.50,10.00,1,'P','Small');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-3','FI-SW-02',18.50,12.00,1,'P','Toothless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-4','FI-FW-01',18.50,12.00,1,'P','Spotted');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-5','FI-FW-01',18.50,12.00,1,'P','Spotless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-6','K9-BD-01',18.50,12.00,1,'P','Male Adult');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-7','K9-BD-01',18.50,12.00,1,'P','Female Puppy');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-8','K9-PO-02',18.50,12.00,1,'P','Male Puppy');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-9','K9-DL-01',18.50,12.00,1,'P','Spotless Male Puppy');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-10','K9-DL-01',18.50,12.00,1,'P','Spotted Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-11','RP-SN-01',18.50,12.00,1,'P','Venomless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-12','RP-SN-01',18.50,12.00,1,'P','Rattleless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-13','RP-LI-02',18.50,12.00,1,'P','Green Adult');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-14','FL-DSH-01',58.50,12.00,1,'P','Tailless');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-15','FL-DSH-01',23.50,12.00,1,'P','With tail');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-16','FL-DLH-02',93.50,12.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-17','FL-DLH-02',93.50,12.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-18','AV-CB-01',193.50,92.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-19','AV-SB-02',15.50, 2.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-20','FI-FW-02',5.50, 2.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-21','FI-FW-02',5.29, 1.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-22','K9-RT-02',135.50, 100.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-23','K9-RT-02',145.49, 100.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-24','K9-RT-02',255.50, 92.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-25','K9-RT-02',325.29, 90.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-26','K9-CW-01',125.50, 92.00,1,'P','Adult Male');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-27','K9-CW-01',155.29, 90.00,1,'P','Adult Female');
+INSERT INTO  item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-28','K9-RT-01',155.29, 90.00,1,'P','Adult Female');
+
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-1',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-2',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-3',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-4',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-5',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-6',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-7',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-8',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-9',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-10',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-11',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-12',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-13',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-14',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-15',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-16',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-17',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-18',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-19',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-20',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-21',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-22',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-23',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-24',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-25',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-26',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-27',10000);
+INSERT INTO inventory (itemid, qty ) VALUES ('EST-28',10000);
+
+select * from inventory;
\ No newline at end of file

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb-schema.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb-schema.sql?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb-schema.sql (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb-schema.sql Thu Aug  7 16:21:46 2008
@@ -0,0 +1,168 @@
+drop index productCat;
+drop index productName;
+drop index itemProd;
+
+drop table lineitem;
+drop table orderstatus;
+drop table orders;
+drop table bannerdata;
+drop table profile;
+drop table signon;
+drop table inventory;
+drop table item;
+drop table product;
+drop table account;
+drop table category;
+drop table supplier;
+drop table sequence;
+
+create table supplier (
+    suppid int not null,
+    name varchar(80) null,
+    status varchar(2) not null,
+    addr1 varchar(80) null,
+    addr2 varchar(80) null,
+    city varchar(80) null,
+    state varchar(80) null,
+    zip varchar(5) null,
+    phone varchar(80) null,
+    constraint pk_supplier primary key (suppid)
+);
+
+create table signon (
+    username varchar(25) not null,
+    password varchar(25)  not null,
+    constraint pk_signon primary key (username)
+);
+
+create table account (
+    userid varchar(80) not null,
+    email varchar(80) not null,
+    firstname varchar(80) not null,
+    lastname varchar(80) not null,
+    status varchar(2)  null,
+    addr1 varchar(80) not null,
+    addr2 varchar(40) null,
+    city varchar(80) not  null,
+    state varchar(80) not null,
+    zip varchar(20) not null,
+    country varchar(20) not null,
+    phone varchar(80) not null,
+    constraint pk_account primary key (userid)
+);
+
+create table profile (
+    userid varchar(80) not null,
+    langpref varchar(80) not null,
+    favcategory varchar(30),
+    mylistopt int,
+    banneropt int,
+    constraint pk_profile primary key (userid)
+);
+
+create table bannerdata (
+    favcategory varchar(80) not null,
+    bannername varchar(255)  null,
+    constraint pk_bannerdata primary key (favcategory)
+);
+
+create table orders (
+      orderid int not null,
+      userid varchar(80) not null,
+      orderdate date not null,
+      shipaddr1 varchar(80) not null,
+      shipaddr2 varchar(80) null,
+      shipcity varchar(80) not null,
+      shipstate varchar(80) not null,
+      shipzip varchar(20) not null,
+      shipcountry varchar(20) not null,
+      billaddr1 varchar(80) not null,
+      billaddr2 varchar(80)  null,
+      billcity varchar(80) not null,
+      billstate varchar(80) not null,
+      billzip varchar(20) not null,
+      billcountry varchar(20) not null,
+      courier varchar(80) not null,
+      totalprice decimal(10,2) not null,
+      billtofirstname varchar(80) not null,
+      billtolastname varchar(80) not null,
+      shiptofirstname varchar(80) not null,
+      shiptolastname varchar(80) not null,
+      creditcard varchar(80) not null,
+      exprdate varchar(7) not null,
+      cardtype varchar(80) not null,
+      locale varchar(80) not null,
+      constraint pk_orders primary key (orderid)
+);
+
+create table orderstatus (
+      orderid int not null,
+      linenum int not null,
+      timestamp date not null,
+      status varchar(2) not null,
+      constraint pk_orderstatus primary key (orderid, linenum)
+);
+
+create table lineitem (
+      orderid int not null,
+      linenum int not null,
+      itemid varchar(10) not null,
+      quantity int not null,
+      unitprice decimal(10,2) not null,
+      constraint pk_lineitem primary key (orderid, linenum)
+);
+
+create table category (
+	catid varchar(10) not null,
+	name varchar(80) null,
+	descn varchar(255) null,
+	constraint pk_category primary key (catid)
+);
+
+create table product (
+    productid varchar(10) not null,
+    category varchar(10) not null,
+    name varchar(80) null,
+    descn varchar(255) null,
+    constraint pk_product primary key (productid),
+        constraint fk_product_1 foreign key (category)
+        references category (catid)
+);
+
+create index productCat on product (category);
+create index productName on product (name);
+
+create table item (
+    itemid varchar(10) not null,
+    productid varchar(10) not null,
+    listprice decimal(10,2) null,
+    unitcost decimal(10,2) null,
+    supplier int null,
+    status varchar(2) null,
+    attr1 varchar(80) null,
+    attr2 varchar(80) null,
+    attr3 varchar(80) null,
+    attr4 varchar(80) null,
+    attr5 varchar(80) null,
+    constraint pk_item primary key (itemid),
+        constraint fk_item_1 foreign key (productid)
+        references product (productid),
+        constraint fk_item_2 foreign key (supplier)
+        references supplier (suppid)
+);
+
+create index itemProd on item (productid);
+
+create table inventory (
+    itemid varchar(10) not null,
+    qty int not null,
+    constraint pk_inventory primary key (itemid)
+);
+
+CREATE TABLE sequence
+(
+    name               varchar(30)  not null,
+    nextid             int          not null,
+    constraint pk_sequence primary key (name)
+);
+

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb.properties?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb.properties (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/databases/jpetstore/jpetstore-hsqldb.properties Thu Aug  7 16:21:46 2008
@@ -0,0 +1,5 @@
+driver=org.hsqldb.jdbcDriver
+url=jdbc:hsqldb:.
+username=sa
+password=
+

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Author.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Author.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Author.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Author.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,109 @@
+package domain.blog;
+
+import java.io.Serializable;
+
+public class Author implements Serializable {
+
+  private int id;
+  private String username;
+  private String password;
+  private String email;
+  private String bio;
+  private Section favouriteSection;
+
+  public Author() {
+  }
+
+  public Author(int id, String username, String password, String email, String bio, Section section) {
+    this.id = id;
+    this.username = username;
+    this.password = password;
+    this.email = email;
+    this.bio = bio;
+    this.favouriteSection = section;
+  }
+
+  public Author(int id) {
+    this.id = id;
+  }
+
+  public int getId() {
+    return id;
+  }
+
+  public void setId(int id) {
+    this.id = id;
+  }
+
+  public String getUsername() {
+    return username;
+  }
+
+  public void setUsername(String username) {
+    this.username = username;
+  }
+
+  public String getPassword() {
+    return password;
+  }
+
+  public void setPassword(String password) {
+    this.password = password;
+  }
+
+  public String getEmail() {
+    return email;
+  }
+
+  public void setEmail(String email) {
+    this.email = email;
+  }
+
+  public String getBio() {
+    return bio;
+  }
+
+  public void setBio(String bio) {
+    this.bio = bio;
+  }
+
+  public Section getFavouriteSection() {
+    return favouriteSection;
+  }
+
+  public void setFavouriteSection(Section favouriteSection) {
+    this.favouriteSection = favouriteSection;
+  }
+
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (!(o instanceof Author)) return false;
+
+    Author author = (Author) o;
+
+    if (id != author.id) return false;
+    if (bio != null ? !bio.equals(author.bio) : author.bio != null) return false;
+    if (email != null ? !email.equals(author.email) : author.email != null) return false;
+    if (password != null ? !password.equals(author.password) : author.password != null) return false;
+    if (username != null ? !username.equals(author.username) : author.username != null) return false;
+    if (favouriteSection != null ? !favouriteSection.equals(author.favouriteSection) : author.favouriteSection != null)
+      return false;
+
+    return true;
+  }
+
+  public int hashCode() {
+    int result;
+    result = id;
+    result = 31 * result + (username != null ? username.hashCode() : 0);
+    result = 31 * result + (password != null ? password.hashCode() : 0);
+    result = 31 * result + (email != null ? email.hashCode() : 0);
+    result = 31 * result + (bio != null ? bio.hashCode() : 0);
+    result = 31 * result + (favouriteSection != null ? favouriteSection.hashCode() : 0);
+    return result;
+  }
+
+  public String toString() {
+    return id + " " + username + " " + password + " " + email;
+  }
+}
\ No newline at end of file

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Blog.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Blog.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Blog.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Blog.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,43 @@
+package domain.blog;
+
+import java.util.List;
+
+public class Blog {
+
+  private int id;
+  private Author author;
+  private String title;
+  private List<Post> posts;
+
+  public int getId() {
+    return id;
+  }
+
+  public void setId(int id) {
+    this.id = id;
+  }
+
+  public Author getAuthor() {
+    return author;
+  }
+
+  public void setAuthor(Author author) {
+    this.author = author;
+  }
+
+  public String getTitle() {
+    return title;
+  }
+
+  public void setTitle(String title) {
+    this.title = title;
+  }
+
+  public List<Post> getPosts() {
+    return posts;
+  }
+
+  public void setPosts(List<Post> posts) {
+    this.posts = posts;
+  }
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Comment.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Comment.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Comment.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Comment.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,41 @@
+package domain.blog;
+
+public class Comment {
+
+  private int id;
+  private Post post;
+  private String name;
+  private String comment;
+
+  public int getId() {
+    return id;
+  }
+
+  public void setId(int id) {
+    this.id = id;
+  }
+
+  public Post getPost() {
+    return post;
+  }
+
+  public void setPost(Post post) {
+    this.post = post;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getComment() {
+    return comment;
+  }
+
+  public void setComment(String comment) {
+    this.comment = comment;
+  }
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Post.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Post.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Post.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Post.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,88 @@
+package domain.blog;
+
+import java.util.*;
+
+public class Post {
+
+  private int id;
+  private Author author;
+  private Blog blog;
+  private Date createdOn;
+  private Section section;
+  private String subject;
+  private String body;
+  private List<Comment> comments;
+  private List<Tag> tags;
+
+  public int getId() {
+    return id;
+  }
+
+  public void setId(int id) {
+    this.id = id;
+  }
+
+  public Blog getBlog() {
+    return blog;
+  }
+
+  public void setBlog(Blog blog) {
+    this.blog = blog;
+  }
+
+  public Author getAuthor() {
+    return author;
+  }
+
+  public void setAuthor(Author author) {
+    this.author = author;
+  }
+
+  public Date getCreatedOn() {
+    return createdOn;
+  }
+
+  public void setCreatedOn(Date createdOn) {
+    this.createdOn = createdOn;
+  }
+
+  public Section getSection() {
+    return section;
+  }
+
+  public void setSection(Section section) {
+    this.section = section;
+  }
+
+  public String getSubject() {
+    return subject;
+  }
+
+  public void setSubject(String subject) {
+    this.subject = subject;
+  }
+
+  public String getBody() {
+    return body;
+  }
+
+  public void setBody(String body) {
+    this.body = body;
+  }
+
+  public List<Comment> getComments() {
+    return comments;
+  }
+
+  public void setComments(List<Comment> comments) {
+    this.comments = comments;
+  }
+
+  public List<Tag> getTags() {
+    return tags;
+  }
+
+  public void setTags(List<Tag> tags) {
+    this.tags = tags;
+  }
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Section.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Section.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Section.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Section.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,7 @@
+package domain.blog;
+
+import java.io.Serializable;
+
+public enum Section implements Serializable {
+  NEWS, VIDEOS, IMAGES, PODCASTS
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Tag.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Tag.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Tag.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/Tag.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,23 @@
+package domain.blog;
+
+public class Tag {
+
+  private int id;
+  private String name;
+
+  public int getId() {
+    return id;
+  }
+
+  public void setId(int id) {
+    this.id = id;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Account.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Account.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Account.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Account.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,171 @@
+package domain.jpetstore;
+
+import java.io.Serializable;
+
+
+public class Account implements Serializable {
+
+  private String username;
+  private String password;
+  private String email;
+  private String firstName;
+  private String lastName;
+  private String status;
+  private String address1;
+  private String address2;
+  private String city;
+  private String state;
+  private String zip;
+  private String country;
+  private String phone;
+  private String favouriteCategoryId;
+  private String languagePreference;
+  private boolean listOption;
+  private boolean bannerOption;
+  private String bannerName;
+
+  public String getUsername() {
+    return username;
+  }
+
+  public void setUsername(String username) {
+    this.username = username;
+  }
+
+  public String getPassword() {
+    return password;
+  }
+
+  public void setPassword(String password) {
+    this.password = password;
+  }
+
+  public String getEmail() {
+    return email;
+  }
+
+  public void setEmail(String email) {
+    this.email = email;
+  }
+
+  public String getFirstName() {
+    return firstName;
+  }
+
+  public void setFirstName(String firstName) {
+    this.firstName = firstName;
+  }
+
+  public String getLastName() {
+    return lastName;
+  }
+
+  public void setLastName(String lastName) {
+    this.lastName = lastName;
+  }
+
+  public String getStatus() {
+    return status;
+  }
+
+  public void setStatus(String status) {
+    this.status = status;
+  }
+
+  public String getAddress1() {
+    return address1;
+  }
+
+  public void setAddress1(String address1) {
+    this.address1 = address1;
+  }
+
+  public String getAddress2() {
+    return address2;
+  }
+
+  public void setAddress2(String address2) {
+    this.address2 = address2;
+  }
+
+  public String getCity() {
+    return city;
+  }
+
+  public void setCity(String city) {
+    this.city = city;
+  }
+
+  public String getState() {
+    return state;
+  }
+
+  public void setState(String state) {
+    this.state = state;
+  }
+
+  public String getZip() {
+    return zip;
+  }
+
+  public void setZip(String zip) {
+    this.zip = zip;
+  }
+
+  public String getCountry() {
+    return country;
+  }
+
+  public void setCountry(String country) {
+    this.country = country;
+  }
+
+  public String getPhone() {
+    return phone;
+  }
+
+  public void setPhone(String phone) {
+    this.phone = phone;
+  }
+
+  public String getFavouriteCategoryId() {
+    return favouriteCategoryId;
+  }
+
+  public void setFavouriteCategoryId(String favouriteCategoryId) {
+    this.favouriteCategoryId = favouriteCategoryId;
+  }
+
+  public String getLanguagePreference() {
+    return languagePreference;
+  }
+
+  public void setLanguagePreference(String languagePreference) {
+    this.languagePreference = languagePreference;
+  }
+
+  public boolean isListOption() {
+    return listOption;
+  }
+
+  public void setListOption(boolean listOption) {
+    this.listOption = listOption;
+  }
+
+  public boolean isBannerOption() {
+    return bannerOption;
+  }
+
+  public void setBannerOption(boolean bannerOption) {
+    this.bannerOption = bannerOption;
+  }
+
+  public String getBannerName() {
+    return bannerName;
+  }
+
+  public void setBannerName(String bannerName) {
+    this.bannerName = bannerName;
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Cart.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Cart.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Cart.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Cart.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,75 @@
+package domain.jpetstore;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.*;
+
+public class Cart implements Serializable {
+
+  private final Map itemMap = Collections.synchronizedMap(new HashMap());
+  private final List itemList = new ArrayList();
+
+  public Iterator getCartItems() {
+    return itemList.iterator();
+  }
+
+  public List getCartItemList() {
+    return itemList;
+  }
+
+  public int getNumberOfItems() {
+    return itemList.size();
+  }
+
+  public boolean containsItemId(String itemId) {
+    return itemMap.containsKey(itemId);
+  }
+
+  public void addItem(Item item, boolean isInStock) {
+    CartItem cartItem = (CartItem) itemMap.get(item.getItemId());
+    if (cartItem == null) {
+      cartItem = new CartItem();
+      cartItem.setItem(item);
+      cartItem.setQuantity(0);
+      cartItem.setInStock(isInStock);
+      itemMap.put(item.getItemId(), cartItem);
+      itemList.add(cartItem);
+    }
+    cartItem.incrementQuantity();
+  }
+
+
+  public Item removeItemById(String itemId) {
+    CartItem cartItem = (CartItem) itemMap.remove(itemId);
+    if (cartItem == null) {
+      return null;
+    } else {
+      itemList.remove(cartItem);
+      return cartItem.getItem();
+    }
+  }
+
+  public void incrementQuantityByItemId(String itemId) {
+    CartItem cartItem = (CartItem) itemMap.get(itemId);
+    cartItem.incrementQuantity();
+  }
+
+  public void setQuantityByItemId(String itemId, int quantity) {
+    CartItem cartItem = (CartItem) itemMap.get(itemId);
+    cartItem.setQuantity(quantity);
+  }
+
+  public BigDecimal getSubTotal() {
+    BigDecimal subTotal = new BigDecimal("0");
+    Iterator items = getCartItems();
+    while (items.hasNext()) {
+      CartItem cartItem = (CartItem) items.next();
+      Item item = cartItem.getItem();
+      BigDecimal listPrice = item.getListPrice();
+      BigDecimal quantity = new BigDecimal(String.valueOf(cartItem.getQuantity()));
+      subTotal = subTotal.add(listPrice.multiply(quantity));
+    }
+    return subTotal;
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/CartItem.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/CartItem.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/CartItem.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/CartItem.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,57 @@
+package domain.jpetstore;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+
+public class CartItem implements Serializable {
+
+  private Item item;
+  private int quantity;
+  private boolean inStock;
+  private BigDecimal total;
+
+  public boolean isInStock() {
+    return inStock;
+  }
+
+  public void setInStock(boolean inStock) {
+    this.inStock = inStock;
+  }
+
+  public BigDecimal getTotal() {
+    return total;
+  }
+
+  public Item getItem() {
+    return item;
+  }
+
+  public void setItem(Item item) {
+    this.item = item;
+    calculateTotal();
+  }
+
+  public int getQuantity() {
+    return quantity;
+  }
+
+  public void setQuantity(int quantity) {
+    this.quantity = quantity;
+    calculateTotal();
+  }
+
+  public void incrementQuantity() {
+    quantity++;
+    calculateTotal();
+  }
+
+  private void calculateTotal() {
+    if (item != null && item.getListPrice() != null) {
+      total = item.getListPrice().multiply(new BigDecimal(quantity));
+    } else {
+      total = null;
+    }
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Category.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Category.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Category.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Category.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,40 @@
+package domain.jpetstore;
+
+import java.io.Serializable;
+
+
+public class Category implements Serializable {
+
+  private String categoryId;
+  private String name;
+  private String description;
+
+  public String getCategoryId() {
+    return categoryId;
+  }
+
+  public void setCategoryId(String categoryId) {
+    this.categoryId = categoryId.trim();
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  public String toString() {
+    return getCategoryId();
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Item.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Item.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Item.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/Item.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,130 @@
+package domain.jpetstore;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+public class Item implements Serializable {
+
+  private String itemId;
+  private String productId;
+  private BigDecimal listPrice;
+  private BigDecimal unitCost;
+  private int supplierId;
+  private String status;
+  private String attribute1;
+  private String attribute2;
+  private String attribute3;
+  private String attribute4;
+  private String attribute5;
+  private Product product;
+  private int quantity;
+
+  public String getItemId() {
+    return itemId;
+  }
+
+  public void setItemId(String itemId) {
+    this.itemId = itemId.trim();
+  }
+
+  public int getQuantity() {
+    return quantity;
+  }
+
+  public void setQuantity(int quantity) {
+    this.quantity = quantity;
+  }
+
+  public Product getProduct() {
+    return product;
+  }
+
+  public void setProduct(Product product) {
+    this.product = product;
+  }
+
+  public String getProductId() {
+    return productId;
+  }
+
+  public void setProductId(String productId) {
+    this.productId = productId;
+  }
+
+  public int getSupplierId() {
+    return supplierId;
+  }
+
+  public void setSupplierId(int supplierId) {
+    this.supplierId = supplierId;
+  }
+
+  public BigDecimal getListPrice() {
+    return listPrice;
+  }
+
+  public void setListPrice(BigDecimal listPrice) {
+    this.listPrice = listPrice;
+  }
+
+  public BigDecimal getUnitCost() {
+    return unitCost;
+  }
+
+  public void setUnitCost(BigDecimal unitCost) {
+    this.unitCost = unitCost;
+  }
+
+  public String getStatus() {
+    return status;
+  }
+
+  public void setStatus(String status) {
+    this.status = status;
+  }
+
+  public String getAttribute1() {
+    return attribute1;
+  }
+
+  public void setAttribute1(String attribute1) {
+    this.attribute1 = attribute1;
+  }
+
+  public String getAttribute2() {
+    return attribute2;
+  }
+
+  public void setAttribute2(String attribute2) {
+    this.attribute2 = attribute2;
+  }
+
+  public String getAttribute3() {
+    return attribute3;
+  }
+
+  public void setAttribute3(String attribute3) {
+    this.attribute3 = attribute3;
+  }
+
+  public String getAttribute4() {
+    return attribute4;
+  }
+
+  public void setAttribute4(String attribute4) {
+    this.attribute4 = attribute4;
+  }
+
+  public String getAttribute5() {
+    return attribute5;
+  }
+
+  public void setAttribute5(String attribute5) {
+    this.attribute5 = attribute5;
+  }
+
+  public String toString() {
+    return "(" + getItemId() + "-" + getProductId() + ")";
+  }
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/LineItem.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/LineItem.java?rev=683745&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/LineItem.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/jpetstore/LineItem.java Thu Aug  7 16:21:46 2008
@@ -0,0 +1,91 @@
+package domain.jpetstore;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+
+public class LineItem implements Serializable {
+
+  private int orderId;
+  private int lineNumber;
+  private int quantity;
+  private String itemId;
+  private BigDecimal unitPrice;
+  private Item item;
+  private BigDecimal total;
+
+  public LineItem() {
+  }
+
+  public LineItem(int lineNumber, CartItem cartItem) {
+    this.lineNumber = lineNumber;
+    this.quantity = cartItem.getQuantity();
+    this.itemId = cartItem.getItem().getItemId();
+    this.unitPrice = cartItem.getItem().getListPrice();
+    this.item = cartItem.getItem();
+  }
+
+  public int getOrderId() {
+    return orderId;
+  }
+
+  public void setOrderId(int orderId) {
+    this.orderId = orderId;
+  }
+
+  public int getLineNumber() {
+    return lineNumber;
+  }
+
+  public void setLineNumber(int lineNumber) {
+    this.lineNumber = lineNumber;
+  }
+
+  public String getItemId() {
+    return itemId;
+  }
+
+  public void setItemId(String itemId) {
+    this.itemId = itemId;
+  }
+
+  public BigDecimal getUnitPrice() {
+    return unitPrice;
+  }
+
+  public void setUnitPrice(BigDecimal unitprice) {
+    this.unitPrice = unitprice;
+  }
+
+  public BigDecimal getTotal() {
+    return total;
+  }
+
+  public Item getItem() {
+    return item;
+  }
+
+  public void setItem(Item item) {
+    this.item = item;
+    calculateTotal();
+  }
+
+  public int getQuantity() {
+    return quantity;
+  }
+
+  public void setQuantity(int quantity) {
+    this.quantity = quantity;
+    calculateTotal();
+  }
+
+  private void calculateTotal() {
+    if (item != null && item.getListPrice() != null) {
+      total = item.getListPrice().multiply(new BigDecimal(quantity));
+    } else {
+      total = null;
+    }
+  }
+
+
+}