本文整理匯總了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;
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}
示例8: newMetaObject
import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
public MetaObject newMetaObject(Object object) {
return MetaObject.forObject(object, objectFactory, objectWrapperFactory, reflectorFactory);
}
示例9: newMetaObject
import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
public MetaObject newMetaObject(Object object) {
return MetaObject
.forObject(object, objectFactory, objectWrapperFactory);
}
示例10: newMetaObject
import org.apache.ibatis.reflection.MetaObject; //導入方法依賴的package包/類
public MetaObject newMetaObject(Object object) {
return MetaObject.forObject(object, objectFactory, objectWrapperFactory, reflectorFactory);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}