本文整理汇总了Java中org.apache.ibatis.reflection.SystemMetaObject类的典型用法代码示例。如果您正苦于以下问题:Java SystemMetaObject类的具体用法?Java SystemMetaObject怎么用?Java SystemMetaObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SystemMetaObject类属于org.apache.ibatis.reflection包,在下文中一共展示了SystemMetaObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: andEqualTo
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
/**
* 将此对象的不为空的字段参数作为相等查询条件
*
* @param param 参数对象
* @author Bob {@link}[email protected]
* @Date 2015年7月17日 下午12:48:08
*/
public Criteria andEqualTo(Object param) {
MetaObject metaObject = SystemMetaObject.forObject(param);
String[] properties = metaObject.getGetterNames();
for (String property : properties) {
//属性和列对应Map中有此属性
if (propertyMap.get(property) != null) {
Object value = metaObject.getValue(property);
//属性值不为空
if (value != null) {
andEqualTo(property, value);
}
}
}
return (Criteria) this;
}
示例2: checkCache
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
/**
* 检查是否配置过缓存
*
* @param ms
* @throws Exception
*/
private void checkCache(MappedStatement ms) throws Exception {
if (ms.getCache() == null) {
String nameSpace = ms.getId().substring(0, ms.getId().lastIndexOf("."));
Cache cache;
try {
//不存在的时候会抛出异常
cache = ms.getConfiguration().getCache(nameSpace);
} catch (IllegalArgumentException e) {
return;
}
if (cache != null) {
MetaObject metaObject = SystemMetaObject.forObject(ms);
metaObject.setValue("cache", cache);
}
}
}
示例3: andAllEqualTo
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
/**
* 将此对象的所有字段参数作为相等查询条件,如果字段为 null,则为 is null
*
* @param param 参数对象
*/
public Criteria andAllEqualTo(Object param) {
MetaObject metaObject = SystemMetaObject.forObject(param);
String[] properties = metaObject.getGetterNames();
for (String property : properties) {
//属性和列对应Map中有此属性
if (propertyMap.get(property) != null) {
Object value = metaObject.getValue(property);
//属性值不为空
if (value != null) {
andEqualTo(property, value);
} else {
andIsNull(property);
}
}
}
return (Criteria) this;
}
示例4: intercept
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
@Override
public Object intercept(Invocation invocation) throws Throwable {
// TODO Auto-generated method stub
if (invocation.getTarget() instanceof RoutingStatementHandler) {
StatementHandler statementHandler = (RoutingStatementHandler) invocation.getTarget();
MetaObject metaStatementHandler = SystemMetaObject.forObject(statementHandler);
MappedStatement mappedStatement = (MappedStatement) metaStatementHandler.getValue("delegate.mappedStatement");
String mapperId = mappedStatement.getId();
String mapperClassName = mapperId.substring(0, mapperId.lastIndexOf("."));
Class<?> mapperClass = Class.forName(mapperClassName);
if (isDaoMapper(mapperClass)&&mapperId.endsWith(".insertUseReturnGeneratedKeys")) {
BaseStatementHandler baseStatementHandler = (BaseStatementHandler) metaStatementHandler.getValue("delegate");
if ("query".equals(invocation.getMethod().getName())) {
return handPreparedStatementHandlerQuery(invocation, baseStatementHandler);
} else if ("prepare".equals(invocation.getMethod().getName())) {
return handPreparedStatementHandlerPrepare(invocation, baseStatementHandler);
}
}
}
return invocation.proceed();
}
示例5: getSetterType
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
@Override
public Class<?> getSetterType(String name) {
PropertyTokenizer prop = new PropertyTokenizer(name);
if (prop.hasNext()) {
MetaObject metaValue = metaObject.metaObjectForProperty(prop.getIndexedName());
if (metaValue == SystemMetaObject.NULL_META_OBJECT) {
return Object.class;
} else {
return metaValue.getSetterType(prop.getChildren());
}
} else {
if (map.get(name) != null) {
return map.get(name).getClass();
} else {
return Object.class;
}
}
}
示例6: getGetterType
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
@Override
public Class<?> getGetterType(String name) {
PropertyTokenizer prop = new PropertyTokenizer(name);
if (prop.hasNext()) {
MetaObject metaValue = metaObject.metaObjectForProperty(prop.getIndexedName());
if (metaValue == SystemMetaObject.NULL_META_OBJECT) {
return Object.class;
} else {
return metaValue.getGetterType(prop.getChildren());
}
} else {
if (map.get(name) != null) {
return map.get(name).getClass();
} else {
return Object.class;
}
}
}
示例7: hasGetter
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
@Override
public boolean hasGetter(String name) {
PropertyTokenizer prop = new PropertyTokenizer(name);
if (prop.hasNext()) {
if (map.containsKey(prop.getIndexedName())) {
MetaObject metaValue = metaObject.metaObjectForProperty(prop.getIndexedName());
if (metaValue == SystemMetaObject.NULL_META_OBJECT) {
return true;
} else {
return metaValue.hasGetter(prop.getChildren());
}
} else {
return false;
}
} else {
return map.containsKey(prop.getName());
}
}
示例8: hasSetter
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
@Override
public boolean hasSetter(String name) {
PropertyTokenizer prop = new PropertyTokenizer(name);
if (prop.hasNext()) {
if (metaClass.hasSetter(prop.getIndexedName())) {
MetaObject metaValue = metaObject.metaObjectForProperty(prop.getIndexedName());
if (metaValue == SystemMetaObject.NULL_META_OBJECT) {
return metaClass.hasSetter(name);
} else {
return metaValue.hasSetter(prop.getChildren());
}
} else {
return false;
}
} else {
return metaClass.hasSetter(name);
}
}
示例9: hasGetter
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
@Override
public boolean hasGetter(String name) {
PropertyTokenizer prop = new PropertyTokenizer(name);
if (prop.hasNext()) {
if (metaClass.hasGetter(prop.getIndexedName())) {
MetaObject metaValue = metaObject.metaObjectForProperty(prop.getIndexedName());
if (metaValue == SystemMetaObject.NULL_META_OBJECT) {
return metaClass.hasGetter(name);
} else {
return metaValue.hasGetter(prop.getChildren());
}
} else {
return false;
}
} else {
return metaClass.hasGetter(name);
}
}
示例10: plugin
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
@Override
public Object plugin(Object target) {
if (target instanceof StatementHandler) {
StatementHandler statementHandler = (StatementHandler) target;
MetaObject metaStatementHandler = SystemMetaObject.forObject(statementHandler);
String sql = statementHandler.getBoundSql().getSql();
Pager pager = Pager.getAndReset();
if (pager != null && sql.trim().toLowerCase().startsWith("select")) {
String newSql = EasyOrmSqlBuilder.getInstance()
.getActiveDatabase().getDialect()
.doPaging(sql, pager.pageIndex(), pager.pageSize());
metaStatementHandler.setValue("delegate.boundSql.sql", newSql);
}
}
return Plugin.wrap(target, this);
}
示例11: intercept
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
@Override
public Object intercept(Invocation invocation) throws Throwable {
StatementHandler statementHandler = (StatementHandler) invocation.getTarget();
if(statementHandler instanceof RoutingStatementHandler){
RoutingStatementHandler routeStatementHandler = (RoutingStatementHandler)statementHandler;
MetaObject metaObject = SystemMetaObject.forObject(routeStatementHandler);
int offset = Integer.valueOf(String.valueOf(metaObject.getValue("delegate.rowBounds.offset")));
int limit = Integer.valueOf(String.valueOf(metaObject.getValue("delegate.rowBounds.limit")));
if(offset == RowBounds.NO_ROW_OFFSET && limit == RowBounds.NO_ROW_LIMIT){
return invocation.proceed();
}
String sql = String.valueOf(metaObject.getValue("delegate.boundSql.sql")).trim();
if(StringUtils.isBlank(sql) || !sql.toLowerCase().startsWith("select")){
return invocation.proceed();
}
String pagedSql = this.buildPagedSql(sql, offset, limit);
metaObject.setValue("delegate.boundSql.sql", pagedSql);
metaObject.setValue("delegate.rowBounds.offset", RowBounds.NO_ROW_OFFSET);
metaObject.setValue("delegate.rowBounds.limit", RowBounds.NO_ROW_LIMIT);
}else{
return invocation.proceed();
}
return invocation.proceed();
}
示例12: getSetterType
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
public Class<?> getSetterType(String name) {
PropertyTokenizer prop = new PropertyTokenizer(name);
if (prop.hasNext()) {
MetaObject metaValue = metaObject.metaObjectForProperty(prop
.getIndexedName());
if (metaValue == SystemMetaObject.NULL_META_OBJECT) {
return Object.class;
} else {
return metaValue.getSetterType(prop.getChildren());
}
} else {
if (map.get(name) != null) {
return map.get(name).getClass();
} else {
return Object.class;
}
}
}
示例13: getGetterType
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
public Class<?> getGetterType(String name) {
PropertyTokenizer prop = new PropertyTokenizer(name);
if (prop.hasNext()) {
MetaObject metaValue = metaObject.metaObjectForProperty(prop
.getIndexedName());
if (metaValue == SystemMetaObject.NULL_META_OBJECT) {
return Object.class;
} else {
return metaValue.getGetterType(prop.getChildren());
}
} else {
if (map.get(name) != null) {
return map.get(name).getClass();
} else {
return Object.class;
}
}
}
示例14: hasGetter
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
public boolean hasGetter(String name) {
PropertyTokenizer prop = new PropertyTokenizer(name);
if (prop.hasNext()) {
if (map.containsKey(prop.getIndexedName())) {
MetaObject metaValue = metaObject.metaObjectForProperty(prop
.getIndexedName());
if (metaValue == SystemMetaObject.NULL_META_OBJECT) {
return true;
} else {
return metaValue.hasGetter(prop.getChildren());
}
} else {
return false;
}
} else {
return map.containsKey(prop.getName());
}
}
示例15: hasSetter
import org.apache.ibatis.reflection.SystemMetaObject; //导入依赖的package包/类
public boolean hasSetter(String name) {
PropertyTokenizer prop = new PropertyTokenizer(name);
if (prop.hasNext()) {
if (metaClass.hasSetter(prop.getIndexedName())) {
MetaObject metaValue = metaObject.metaObjectForProperty(prop
.getIndexedName());
if (metaValue == SystemMetaObject.NULL_META_OBJECT) {
return metaClass.hasSetter(name);
} else {
return metaValue.hasSetter(prop.getChildren());
}
} else {
return false;
}
} else {
return metaClass.hasSetter(name);
}
}