ibatis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbe...@apache.org
Subject svn commit: r746560 - in /ibatis/trunk/java/ibatis-3: ./ ibatis-3-core/src/main/java/org/apache/ibatis/annotations/ ibatis-3-core/src/main/java/org/apache/ibatis/api/ ibatis-3-core/src/main/java/org/apache/ibatis/api/annotations/ ibatis-3-core/src/main...
Date Sat, 21 Feb 2009 18:44:12 GMT
Author: cbegin
Date: Sat Feb 21 18:44:10 2009
New Revision: 746560

URL: http://svn.apache.org/viewvc?rev=746560&view=rev
Log:
refactored annotations and api package

Added:
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/
      - copied from r746441, ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/annotations/
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Annotations.java
      - copied, changed from r746441, ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/annotations/Result.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/binding/MapperRegistry.java
      - copied, changed from r746441, ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/binding/MapperFactory.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/exceptions/
      - copied from r746441, ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/exceptions/
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/BoundBlogMapper.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/IbatisConfig.java
Removed:
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Cache.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/CacheRefNamespace.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Collection.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Collections.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Delete.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Insert.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Param.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Property.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/QueryMethod.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Result.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/ResultClass.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Results.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Select.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Undefined.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Update.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/annotations/
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/exceptions/
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/binding/MapperFactory.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/domain/blog/mappers/AnnoMapper.java
Modified:
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/SqlSessionFactoryBuilder.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/defaults/DefaultSqlSession.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/defaults/DefaultSqlSessionFactory.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/exceptions/ExceptionFactory.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/exceptions/RuntimeSqlException.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/mapping/Configuration.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/mapping/Environment.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/api/SqlSessionTest.java
    ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/BindingTest.java
    ibatis/trunk/java/ibatis-3/version.properties

Copied: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Annotations.java
(from r746441, ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/annotations/Result.java)
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Annotations.java?p2=ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Annotations.java&p1=ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/annotations/Result.java&r1=746441&r2=746560&rev=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/annotations/Result.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/annotations/Annotations.java
Sat Feb 21 18:44:10 2009
@@ -1,21 +1,100 @@
-package org.apache.ibatis.api.annotations;
+package org.apache.ibatis.annotations;
 
+import org.apache.ibatis.cache.decorators.LruCache;
+import org.apache.ibatis.cache.impl.PerpetualCache;
 import org.apache.ibatis.type.JdbcType;
 
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface Result {
-
-  String column() default "";
-  String property() default "";
-  String field() default "";
-  JdbcType jdbcType() default JdbcType.UNDEFINED;
-  Class typeHandler() default Undefined.class;
-  QueryMethod nestedQuery() default @QueryMethod(type= Undefined.class, methodName="", parameters="");
+import java.lang.annotation.*;
+
+public class Annotations {
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.METHOD)
+  public static @interface ConstructorArgs {
+    Arg[] value() default {};
+  }
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.METHOD)
+  public static @interface Arg {
+    boolean id() default false;
+    String column() default "";
+    Class javaType() default Class.class;
+    JdbcType jdbcType() default JdbcType.UNDEFINED;
+    Class typeHandler() default Class.class;
+  }
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.METHOD)
+  public static @interface Results {
+    Result[] value() default {};
+  }
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.METHOD)
+  public static @interface Result {
+    boolean key() default false;
+    String column() default "";
+    String property() default "";
+    Class javaType() default Class.class;
+    JdbcType jdbcType() default JdbcType.UNDEFINED;
+    Class typeHandler() default Class.class;
+    String collectionSelect() default "";
+    Results collectionResults() default @Results;
+    String associationSelect() default "";
+    Results associationResults() default @Results;
+  }
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.TYPE)
+  public static @interface Cache {
+    Class<? extends org.apache.ibatis.cache.Cache> type() default PerpetualCache.class;
+    Class<? extends org.apache.ibatis.cache.Cache> eviction() default LruCache.class;
+    int flushInterval() default 3600000;
+    int size() default 1000;
+    boolean readOnly() default false;
+  }
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.TYPE)
+  public @interface CacheRefNamespace {
+    String[] value();
+  }
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.METHOD)
+  public @interface Insert {
+    String[] value();
+  }
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.METHOD)
+  public @interface Update {
+    String[] value();
+  }
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.METHOD)
+  public @interface Delete {
+    String[] value();
+  }
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.METHOD)
+  public @interface Select {
+    String[] value();
+  }
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.METHOD)
+  public @interface Procedure {
+    String[] value();
+  }
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.METHOD)
+  public @interface Statement {
+    String[] value();
+  }
 
 }

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/SqlSessionFactoryBuilder.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/SqlSessionFactoryBuilder.java?rev=746560&r1=746559&r2=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/SqlSessionFactoryBuilder.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/SqlSessionFactoryBuilder.java
Sat Feb 21 18:44:10 2009
@@ -1,7 +1,7 @@
 package org.apache.ibatis.api;
 
 import org.apache.ibatis.api.defaults.DefaultSqlSessionFactory;
-import org.apache.ibatis.api.exceptions.ExceptionFactory;
+import org.apache.ibatis.exceptions.ExceptionFactory;
 import org.apache.ibatis.mapping.Configuration;
 import org.apache.ibatis.parser.MapperConfigParser;
 

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/defaults/DefaultSqlSession.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/defaults/DefaultSqlSession.java?rev=746560&r1=746559&r2=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/defaults/DefaultSqlSession.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/defaults/DefaultSqlSession.java
Sat Feb 21 18:44:10 2009
@@ -2,12 +2,11 @@
 
 import org.apache.ibatis.api.ApiException;
 import org.apache.ibatis.api.SqlSession;
-import org.apache.ibatis.api.exceptions.ExceptionFactory;
+import org.apache.ibatis.exceptions.ExceptionFactory;
 import org.apache.ibatis.executor.Executor;
 import org.apache.ibatis.executor.result.ResultHandler;
 import org.apache.ibatis.mapping.Configuration;
 import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.binding.MapperFactory;
 
 import java.util.List;
 
@@ -143,7 +142,7 @@
   }
 
   public <T> T getMapper(Class<T> type) {
-    return configuration.getMapperFactory().getMapper(type, this);
+    return configuration.getMapper(type, this);
   }
 
   private boolean isCommitOrRollbackRequired(boolean force) {

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/defaults/DefaultSqlSessionFactory.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/defaults/DefaultSqlSessionFactory.java?rev=746560&r1=746559&r2=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/defaults/DefaultSqlSessionFactory.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/api/defaults/DefaultSqlSessionFactory.java
Sat Feb 21 18:44:10 2009
@@ -2,7 +2,7 @@
 
 import org.apache.ibatis.api.SqlSession;
 import org.apache.ibatis.api.SqlSessionFactory;
-import org.apache.ibatis.api.exceptions.ExceptionFactory;
+import org.apache.ibatis.exceptions.ExceptionFactory;
 import org.apache.ibatis.executor.Executor;
 import org.apache.ibatis.logging.Log;
 import org.apache.ibatis.logging.LogFactory;

Copied: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/binding/MapperRegistry.java
(from r746441, ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/binding/MapperFactory.java)
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/binding/MapperRegistry.java?p2=ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/binding/MapperRegistry.java&p1=ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/binding/MapperFactory.java&r1=746441&r2=746560&rev=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/binding/MapperFactory.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/binding/MapperRegistry.java
Sat Feb 21 18:44:10 2009
@@ -1,10 +1,23 @@
 package org.apache.ibatis.binding;
 
 import org.apache.ibatis.api.SqlSession;
+import static org.apache.ibatis.annotations.Annotations.*;
+import org.apache.ibatis.mapping.*;
 
-public class MapperFactory {
+import java.util.*;
+import java.lang.reflect.Method;
+
+public class MapperRegistry {
+
+  private Configuration config;
+  private Set<Class> knownMappers = new HashSet<Class>();
+
+  public MapperRegistry(Configuration config) {
+    this.config = config;
+  }
 
   public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
+    if (!knownMappers.contains(type)) throw new BindingException("Type " + type + " is not
known to the MapperRegistry.");
     try {
       return MapperProxy.newMapperProxy(type, sqlSession);
     } catch (Exception e) {
@@ -12,4 +25,14 @@
     }
   }
 
+  public void addMapper(Class type) {
+    if (!type.isInterface()) throw new BindingException("Only interfaces can be configured
by the MapperFactory.  Type " + type + " is not an interface.");
+    if (knownMappers.contains(type)) throw new BindingException("Type " + type + " is already
known to the MapperRegistry.");
+    knownMappers.add(type);
+    parseAnnotations(type);
+  }
+
+  public void parseAnnotations(Class type) {
+  }
+
 }

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/exceptions/ExceptionFactory.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/exceptions/ExceptionFactory.java?rev=746560&r1=746441&r2=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/exceptions/ExceptionFactory.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/exceptions/ExceptionFactory.java
Sat Feb 21 18:44:10 2009
@@ -1,4 +1,4 @@
-package org.apache.ibatis.api.exceptions;
+package org.apache.ibatis.exceptions;
 
 import org.apache.ibatis.executor.ErrorContext;
 

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/exceptions/RuntimeSqlException.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/exceptions/RuntimeSqlException.java?rev=746560&r1=746441&r2=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/exceptions/RuntimeSqlException.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/exceptions/RuntimeSqlException.java
Sat Feb 21 18:44:10 2009
@@ -1,4 +1,4 @@
-package org.apache.ibatis.api.exceptions;
+package org.apache.ibatis.exceptions;
 
 public class RuntimeSqlException extends RuntimeException {
 

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/mapping/Configuration.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/mapping/Configuration.java?rev=746560&r1=746559&r2=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/mapping/Configuration.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/mapping/Configuration.java
Sat Feb 21 18:44:10 2009
@@ -26,7 +26,8 @@
 import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
 import org.apache.ibatis.type.TypeAliasRegistry;
 import org.apache.ibatis.type.TypeHandlerRegistry;
-import org.apache.ibatis.binding.MapperFactory;
+import org.apache.ibatis.binding.MapperRegistry;
+import org.apache.ibatis.api.SqlSession;
 
 import java.util.Collection;
 import java.util.HashMap;
@@ -48,7 +49,7 @@
 
   private Properties variables = new Properties();
   private ObjectFactory objectFactory = new DefaultObjectFactory();
-  private MapperFactory mapperFactory = new MapperFactory();
+  private MapperRegistry mapperRegistry = new MapperRegistry(this);
 
   private final InterceptorChain interceptorChain = new InterceptorChain();
   private final TypeHandlerRegistry typeHandlerRegistry = new TypeHandlerRegistry();
@@ -58,6 +59,11 @@
   private final Map<String, ResultMap> resultMaps = new StrictMap<String, ResultMap>("Result
Maps collection");
   private final Map<String, ParameterMap> parameterMaps = new StrictMap<String,
ParameterMap>("Parameter Maps collection");
 
+  public Configuration(Environment environment) {
+    this();
+    this.environment = environment;
+  }
+
   public Configuration() {
     typeAliasRegistry.registerAlias("JDBC", JdbcTransactionFactory.class.getName());
     typeAliasRegistry.registerAlias("MANAGED", ManagedTransactionFactory.class.getName());
@@ -276,8 +282,12 @@
     interceptorChain.addInterceptor(interceptor);
   }
 
-  public MapperFactory getMapperFactory() {
-    return mapperFactory;
+  public <T> void addMapper(Class<T> type) {
+    mapperRegistry.addMapper(type);
+  }
+
+  public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
+    return mapperRegistry.getMapper(type,sqlSession);
   }
 
   private static class StrictMap<J, K> extends HashMap<J, K> {

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/mapping/Environment.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/mapping/Environment.java?rev=746560&r1=746559&r2=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/mapping/Environment.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/mapping/Environment.java
Sat Feb 21 18:44:10 2009
@@ -9,6 +9,12 @@
   private TransactionFactory transactionFactory;
   private DataSource dataSource;
 
+  public Environment(String id, TransactionFactory transactionFactory, DataSource dataSource)
{
+    this.id = id;
+    this.transactionFactory = transactionFactory;
+    this.dataSource = dataSource;
+  }
+
   private Environment() {
   }
 

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/api/SqlSessionTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/api/SqlSessionTest.java?rev=746560&r1=746559&r2=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/api/SqlSessionTest.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/api/SqlSessionTest.java
Sat Feb 21 18:44:10 2009
@@ -24,6 +24,8 @@
     final String resource = "org/apache/ibatis/parser/MapperConfig.xml";
     final Reader reader = Resources.getResourceAsReader(resource);
     sqlMapper = new SqlSessionFactoryBuilder().build(reader);
+    sqlMapper.getConfiguration().addMapper(AuthorMapper.class);
+    sqlMapper.getConfiguration().addMapper(BlogMapper.class);
   }
 
   @Test

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/BindingTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/BindingTest.java?rev=746560&r1=746559&r2=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/BindingTest.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/BindingTest.java
Sat Feb 21 18:44:10 2009
@@ -1,28 +1,20 @@
 package org.apache.ibatis.binding;
 
-import org.apache.ibatis.BaseDataTest;
-import org.apache.ibatis.io.Resources;
 import org.apache.ibatis.api.SqlSessionFactory;
-import org.apache.ibatis.api.SqlSessionFactoryBuilder;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import java.io.Reader;
-
-public class BindingTest  extends BaseDataTest {
-  private static SqlSessionFactory sqlMapper;
+public class BindingTest {
+  private static SqlSessionFactory sqlSessionFactory;
 
   @BeforeClass
   public static void setup() throws Exception {
-    createBlogDataSource();
-    final String resource = "org/apache/ibatis/parser/MapperConfig.xml";
-    final Reader reader = Resources.getResourceAsReader(resource);
-    sqlMapper = new SqlSessionFactoryBuilder().build(reader);
+    sqlSessionFactory = new IbatisConfig().getSqlSessionFactory();
   }
 
   @Test
   public void foo() {
-    
+  
   }
 
 

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/BoundBlogMapper.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/BoundBlogMapper.java?rev=746560&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/BoundBlogMapper.java
(added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/BoundBlogMapper.java
Sat Feb 21 18:44:10 2009
@@ -0,0 +1,29 @@
+package org.apache.ibatis.binding;
+
+import domain.blog.Blog;
+import static org.apache.ibatis.annotations.Annotations.*;
+
+@Cache
+public interface BoundBlogMapper {
+
+  @ConstructorArgs({
+      @Arg(id = true, column = ""),
+      @Arg(column = ""),
+      @Arg(column = "")
+      })
+  @Results({
+      @Result(column = "A",property = ""),
+      @Result(column = "B",property = "", collectionSelect = "com.domain.Class.method"),
+      @Result(column = "C",property = "", collectionResults = @Results({
+        @Result(column = "X",property = ""),
+        @Result(column = "Y",property = "")
+      }))
+  })
+  @Select({
+      "SELECT *",
+      "FROM BLOG",
+      "where id = ${id}"
+      })
+  Blog selectBlog(int id);
+
+}

Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/IbatisConfig.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/IbatisConfig.java?rev=746560&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/IbatisConfig.java
(added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/binding/IbatisConfig.java
Sat Feb 21 18:44:10 2009
@@ -0,0 +1,27 @@
+package org.apache.ibatis.binding;
+
+import org.apache.ibatis.api.SqlSessionFactory;
+import org.apache.ibatis.api.defaults.DefaultSqlSessionFactory;
+import org.apache.ibatis.mapping.*;
+import org.apache.ibatis.transaction.TransactionFactory;
+import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
+import org.apache.ibatis.BaseDataTest;
+
+import javax.sql.DataSource;
+
+public class IbatisConfig {
+
+  public static SqlSessionFactory getSqlSessionFactory() {
+    try {
+      DataSource dataSource = BaseDataTest.createBlogDataSource();
+      TransactionFactory transactionFactory = new JdbcTransactionFactory();
+      Environment environment = new Environment("Production", transactionFactory, dataSource);
+      Configuration configuration = new Configuration(environment);
+      configuration.addMapper(BoundBlogMapper.class);
+      return new DefaultSqlSessionFactory(configuration);
+    } catch (Exception e) {
+      throw new RuntimeException("Error initializing SqlSessionFactory. Cause: " + e, e);
+    }
+  }
+
+}

Modified: ibatis/trunk/java/ibatis-3/version.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/version.properties?rev=746560&r1=746559&r2=746560&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/version.properties (original)
+++ ibatis/trunk/java/ibatis-3/version.properties Sat Feb 21 18:44:10 2009
@@ -1,5 +1,5 @@
 #Build version info
-#Fri Feb 20 21:23:36 MST 2009
+#Fri Feb 20 23:51:43 MST 2009
 version=3.0.0
-buildDate=2009/02/20 21\:23
-buildNum=125
+buildDate=2009/02/20 23\:51
+buildNum=127



Mime
View raw message