当前位置: 首页>>代码示例>>Java>>正文


Java MetaObject.forObject方法代码示例

本文整理汇总了Java中org.apache.ibatis.reflection.MetaObject.forObject方法的典型用法代码示例。如果您正苦于以下问题:Java MetaObject.forObject方法的具体用法?Java MetaObject.forObject怎么用?Java MetaObject.forObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.reflection.MetaObject的用法示例。


在下文中一共展示了MetaObject.forObject方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: instantiatePropertyValue

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
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;
}
 
开发者ID:yinshipeng,项目名称:sosoapi-base,代码行数:19,代码来源:BeanWrapper.java

示例2: handleResult

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
@Override
public void handleResult(ResultContext<? extends V> context) {
  final V value = context.getResultObject();
  final MetaObject mo = MetaObject.forObject(value, objectFactory, objectWrapperFactory, reflectorFactory);
  // TODO is that assignment always true?
  final K key = (K) mo.getValue(mapKey);
  mappedResults.put(key, value);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:DefaultMapResultHandler.java

示例3: intercept

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
public Object intercept(Invocation invocation) throws Throwable {
	StatementHandler statementHandler = (StatementHandler)invocation.getTarget();
	MetaObject metaStatementHandler = MetaObject.forObject(statementHandler, new DefaultObjectFactory(), new DefaultObjectWrapperFactory(), new DefaultReflectorFactory());
	RowBounds rowBounds = (RowBounds)metaStatementHandler.getValue("delegate.rowBounds");
	if(rowBounds == null || rowBounds == RowBounds.DEFAULT){
		return invocation.proceed();
	}
	if(dialect == null){
		Configuration configuration = (Configuration) metaStatementHandler.getValue("delegate.configuration");
		Dialect.Type databaseType = null;
		String d = configuration.getVariables().getProperty("dialect");
		if(d == null || d.trim().equals("")){
			throw new IllegalStateException("No property named with 'dialect' defined in mybatis configuration xml file.");
		}
		try {
			databaseType = Dialect.Type.valueOf(d);
		} catch (Exception e) {
			throw new IllegalStateException(String.format("No such dialect enum defined in class %s.", Dialect.Type.class));
		}
		
		switch (databaseType) {
		  	case MYSQL: // MySQL分页
		  		dialect = new MySQLDialect();
		  		break;
		  	case ORACLE: // Oracle分页
		  		dialect = new OracleDialect();
		  		break;
		}
		if(dialect == null){
			throw new IllegalStateException(String.format("No %s dialect found!", databaseType));
		}
	}
	String originalSql = metaStatementHandler.getValue("delegate.boundSql.sql").toString();
	metaStatementHandler.setValue("delegate.boundSql.sql", dialect.getLimitSql(originalSql, rowBounds.getOffset(), rowBounds.getLimit()));
	metaStatementHandler.setValue("delegate.rowBounds.offset", RowBounds.NO_ROW_OFFSET);
       metaStatementHandler.setValue("delegate.rowBounds.limit", RowBounds.NO_ROW_LIMIT);
       return invocation.proceed(); 
}
 
开发者ID:penggle,项目名称:xproject,代码行数:39,代码来源:PaginationInterceptor.java

示例4: findTargetObject

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
public static MetaObject findTargetObject(Invocation invocation) {
    MetaObject metaObject = MetaObject.forObject(invocation.getTarget(), OBJECT_FACTORY, OBJECT_WRAPPER_FACTORY);
    while (metaObject.hasGetter(HANDLER_FIELD)) {
        Object o = metaObject.getValue(HANDLER_FIELD);
        metaObject = MetaObject.forObject(o, OBJECT_FACTORY, OBJECT_WRAPPER_FACTORY);
        if (metaObject.hasGetter(TARGET_FIELD)) {
            o = metaObject.getValue(TARGET_FIELD);
            metaObject = MetaObject.forObject(o, OBJECT_FACTORY, OBJECT_WRAPPER_FACTORY);
        }
    }
    return metaObject;
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:13,代码来源:MetaObjectUtils.java

示例5: instantiatePropertyValue

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
@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(), metaObject.getReflectorFactory());
    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;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:14,代码来源:BeanWrapper.java

示例6: instantiatePropertyValue

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
public MetaObject instantiatePropertyValue(String name,
		PropertyTokenizer prop, ObjectFactory objectFactory) {
	HashMap<String, Object> map = new HashMap<String, Object>();
	set(prop, map);
	return MetaObject.forObject(map, metaObject.getObjectFactory(),
			metaObject.getObjectWrapperFactory());
}
 
开发者ID:yinshipeng,项目名称:sosoapi-base,代码行数:8,代码来源:MapWrapper.java

示例7: instantiatePropertyValue

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
@Override
public MetaObject instantiatePropertyValue(String name, PropertyTokenizer prop, ObjectFactory objectFactory) {
  HashMap<String, Object> map = new HashMap<String, Object>();
  set(prop, map);
  return MetaObject.forObject(map, metaObject.getObjectFactory(), metaObject.getObjectWrapperFactory(), metaObject.getReflectorFactory());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:7,代码来源:MapWrapper.java

示例8: newMetaObject

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
public MetaObject newMetaObject(Object object) {
  return MetaObject.forObject(object, objectFactory, objectWrapperFactory, reflectorFactory);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:4,代码来源:Configuration.java

示例9: newMetaObject

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
public MetaObject newMetaObject(Object object) {
	return MetaObject
			.forObject(object, objectFactory, objectWrapperFactory);
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:5,代码来源:Configuration.java

示例10: newMetaObject

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
public MetaObject newMetaObject(Object object) {
	return MetaObject.forObject(object, objectFactory, objectWrapperFactory, reflectorFactory);
}
 
开发者ID:whatlookingfor,项目名称:spring-boot-sample,代码行数:4,代码来源:Configuration.java

示例11: forObject

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
/**
 * 反射对象,增加对低版本Mybatis的支持
 *
 * @param object 反射对象
 * @return
 */
private static MetaObject forObject(Object object) {
    return MetaObject.forObject(object, DEFAULT_OBJECT_FACTORY, DEFAULT_OBJECT_WRAPPER_FACTORY, DEFAULT_REFLECTION_FACTORY);
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:10,代码来源:SqlUtil.java

示例12: forObject

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
/**
 * 反射对象,增加对低版本Mybatis的支持
 *
 * @param object
 *            反射对象
 * @return
 */
private static MetaObject forObject(Object object) {
    return MetaObject.forObject(object, DEFAULT_OBJECT_FACTORY, DEFAULT_OBJECT_WRAPPER_FACTORY);
}
 
开发者ID:PekingGo,项目名称:ipayquery,代码行数:11,代码来源:SqlUtil.java

示例13: forObject

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
/**
 * 反射对象,增加对低版本Mybatis的支持
 *
 * @param object 反射对象
 * @return
 */
public static MetaObject forObject(Object object) {
    return MetaObject.forObject(object, DEFAULT_OBJECT_FACTORY, DEFAULT_OBJECT_WRAPPER_FACTORY);
}
 
开发者ID:baihui212,项目名称:tsharding,代码行数:10,代码来源:MapperEnhancer.java

示例14: forObject

import org.apache.ibatis.reflection.MetaObject; //导入方法依赖的package包/类
/**
 * 反射对象,增加对低版本Mybatis的支持
 *
 * @param object 反射对象
 * @return
 */
private static MetaObject forObject(Object object) {
    return MetaObject.forObject(object, DEFAULT_OBJECT_FACTORY, DEFAULT_OBJECT_WRAPPER_FACTORY,DEFAULT_REFLECTION_FACTORY);
}
 
开发者ID:lp895876294,项目名称:genericdao,代码行数:10,代码来源:SqlUtil.java


注:本文中的org.apache.ibatis.reflection.MetaObject.forObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。