當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。