Java Code Examples for org.apache.ibatis.reflection.factory.ObjectFactory#create()

The following examples show how to use org.apache.ibatis.reflection.factory.ObjectFactory#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeanWrapper.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Override
public MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory) {
  MetaObject metaValue;
  Class<?> type = getSetterType(prop.getName());
  try {
    Object newObject = objectFactory.create(type);
    metaValue = MetaObject.forObject(newObject, metaObject.getObjectFactory(), metaObject.getObjectWrapperFactory());
    set(prop, newObject);
  } catch (Exception e) {
    throw new ReflectionException("Cannot set value of property '" + name + "' because '" + name + "' is null and cannot be instantiated on instance of " + type.getName() + ". Cause:" + e.toString(), e);
  }
  return metaValue;
}
 
Example 2
Source File: DefaultMapResultHandler.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public DefaultMapResultHandler(String mapKey, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) {
  this.objectFactory = objectFactory;
  this.objectWrapperFactory = objectWrapperFactory;
  this.mappedResults = objectFactory.create(Map.class);
  this.mapKey = mapKey;
}
 
Example 3
Source File: BeanWrapper.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Override
public MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory) {
  MetaObject metaValue;
  Class<?> type = getSetterType(prop.getName());
  try {
    Object newObject = objectFactory.create(type);
    metaValue = MetaObject.forObject(newObject, metaObject.getObjectFactory(), metaObject.getObjectWrapperFactory());
    set(prop, newObject);
  } catch (Exception e) {
    throw new ReflectionException("Cannot set value of property '" + name + "' because '" + name + "' is null and cannot be instantiated on instance of " + type.getName() + ". Cause:" + e.toString(), e);
  }
  return metaValue;
}
 
Example 4
Source File: DefaultMapResultHandler.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public DefaultMapResultHandler(String mapKey, ObjectFactory objectFactory, ObjectWrapperFactory objectWrapperFactory) {
  this.objectFactory = objectFactory;
  this.objectWrapperFactory = objectWrapperFactory;
  this.mappedResults = objectFactory.create(Map.class);
  this.mapKey = mapKey;
}
 
Example 5
Source File: DefaultResultHandler.java    From mybaties with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public DefaultResultHandler(ObjectFactory objectFactory) {
  list = objectFactory.create(List.class);
}
 
Example 6
Source File: DefaultResultHandler.java    From mybatis with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public DefaultResultHandler(ObjectFactory objectFactory) {
  list = objectFactory.create(List.class);
}