本文整理汇总了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);
}