List of usage examples for org.apache.ibatis.scripting.xmltags ForEachSqlNode ITEM_PREFIX
String ITEM_PREFIX
To view the source code for org.apache.ibatis.scripting.xmltags ForEachSqlNode ITEM_PREFIX.
Click Source Link
From source file:com.beginner.core.page.PagePlugin.java
License:Apache License
/** * SQL?(?)/*from ww w. j a v a 2 s .c om*/ * ?org.apache.ibatis.executor.parameter.DefaultParameterHandler */ private void setParameters(PreparedStatement ps, MappedStatement mappedStatement, BoundSql boundSql, Object parameterObject) throws SQLException { ErrorContext.instance().activity("setting parameters").object(mappedStatement.getParameterMap().getId()); List<ParameterMapping> parameterMappings = boundSql.getParameterMappings(); if (parameterMappings != null) { Configuration configuration = mappedStatement.getConfiguration(); TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry(); MetaObject metaObject = parameterObject == null ? null : configuration.newMetaObject(parameterObject); for (int i = 0; i < parameterMappings.size(); i++) { ParameterMapping parameterMapping = parameterMappings.get(i); if (parameterMapping.getMode() != ParameterMode.OUT) { Object value; String propertyName = parameterMapping.getProperty(); PropertyTokenizer prop = new PropertyTokenizer(propertyName); if (parameterObject == null) { value = null; } else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) { value = parameterObject; } else if (boundSql.hasAdditionalParameter(propertyName)) { value = boundSql.getAdditionalParameter(propertyName); } else if (propertyName.startsWith(ForEachSqlNode.ITEM_PREFIX) && boundSql.hasAdditionalParameter(prop.getName())) { value = boundSql.getAdditionalParameter(prop.getName()); if (value != null) { value = configuration.newMetaObject(value) .getValue(propertyName.substring(prop.getName().length())); } } else { value = metaObject == null ? null : metaObject.getValue(propertyName); } TypeHandler typeHandler = parameterMapping.getTypeHandler(); if (typeHandler == null) { throw new ExecutorException("There was no TypeHandler found for parameter " + propertyName + " of statement " + mappedStatement.getId()); } typeHandler.setParameter(ps, i + 1, value, parameterMapping.getJdbcType()); } } } }
From source file:com.eryansky.common.orm.mybatis.interceptor.SQLHelper.java
License:Apache License
/** * SQL?(?),?org.apache.ibatis.executor.parameter.DefaultParameterHandler * * @param ps SQL ?/* ww w . j a v a 2 s . com*/ * @param mappedStatement MappedStatement * @param boundSql SQL * @param parameterObject ? * @throws java.sql.SQLException ? */ @SuppressWarnings("unchecked") public static void setParameters(PreparedStatement ps, MappedStatement mappedStatement, BoundSql boundSql, Object parameterObject) throws SQLException { ErrorContext.instance().activity("setting parameters").object(mappedStatement.getParameterMap().getId()); List<ParameterMapping> parameterMappings = boundSql.getParameterMappings(); if (parameterMappings != null) { Configuration configuration = mappedStatement.getConfiguration(); TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry(); MetaObject metaObject = parameterObject == null ? null : configuration.newMetaObject(parameterObject); for (int i = 0; i < parameterMappings.size(); i++) { ParameterMapping parameterMapping = parameterMappings.get(i); if (parameterMapping.getMode() != ParameterMode.OUT) { Object value; String propertyName = parameterMapping.getProperty(); PropertyTokenizer prop = new PropertyTokenizer(propertyName); if (parameterObject == null) { value = null; } else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) { value = parameterObject; } else if (boundSql.hasAdditionalParameter(propertyName)) { value = boundSql.getAdditionalParameter(propertyName); } else if (propertyName.startsWith(ForEachSqlNode.ITEM_PREFIX) && boundSql.hasAdditionalParameter(prop.getName())) { value = boundSql.getAdditionalParameter(prop.getName()); if (value != null) { value = configuration.newMetaObject(value) .getValue(propertyName.substring(prop.getName().length())); } } else { value = metaObject == null ? null : metaObject.getValue(propertyName); } @SuppressWarnings("rawtypes") TypeHandler typeHandler = parameterMapping.getTypeHandler(); if (typeHandler == null) { throw new ExecutorException("There was no TypeHandler found for parameter " + propertyName + " of statement " + mappedStatement.getId()); } typeHandler.setParameter(ps, i + 1, value, parameterMapping.getJdbcType()); } } } }
From source file:com.github.ibole.infrastructure.persistence.db.mybatis.pagination.DefaultParameterHandler.java
License:Apache License
@SuppressWarnings({ "rawtypes", "unchecked" })
public void setParameters(PreparedStatement ps) throws SQLException {
ErrorContext.instance().activity("setting parameters").object(mappedStatement.getParameterMap().getId());
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
if (parameterMappings != null) {
Configuration configuration = mappedStatement.getConfiguration();
TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
MetaObject metaObject = parameterObject == null ? null : configuration.newMetaObject(parameterObject);
for (int i = 0; i < parameterMappings.size(); i++) {
ParameterMapping parameterMapping = parameterMappings.get(i);
if (parameterMapping.getMode() != ParameterMode.OUT) {
Object value;/*www. j a v a 2 s. c om*/
String propertyName = parameterMapping.getProperty();
PropertyTokenizer prop = new PropertyTokenizer(propertyName);
if (parameterObject == null) {
value = null;
} else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
value = parameterObject;
} else if (boundSql.hasAdditionalParameter(propertyName)) {
value = boundSql.getAdditionalParameter(propertyName);
} else if (propertyName.startsWith(ForEachSqlNode.ITEM_PREFIX)
&& boundSql.hasAdditionalParameter(prop.getName())) {
value = boundSql.getAdditionalParameter(prop.getName());
if (value != null) {
value = configuration.newMetaObject(value)
.getValue(propertyName.substring(prop.getName().length()));
}
} else {
value = metaObject == null ? null : metaObject.getValue(propertyName);
}
TypeHandler typeHandler = parameterMapping.getTypeHandler();
if (typeHandler == null) {
throw new ExecutorException("There was no TypeHandler found for parameter " + propertyName
+ " of statement " + mappedStatement.getId());
}
typeHandler.setParameter(ps, i + 1, value, parameterMapping.getJdbcType());
}
}
}
}
From source file:com.playersun.jbf.common.persistence.mybatis.pagination.CountHelper.java
License:Apache License
/** * SQL?(?)/*from w ww. j a v a 2s . co m*/ * * @param ps * SQL ? * @param mappedStatement * MappedStatement * @param boundSql * SQL * @param parameterObject * ? * @throws java.sql.SQLException * ? */ @SuppressWarnings("unchecked") public static void setParameters(PreparedStatement ps, MappedStatement mappedStatement, BoundSql boundSql, Object parameterObject) throws SQLException { ErrorContext.instance().activity("setting parameters").object(mappedStatement.getParameterMap().getId()); List<ParameterMapping> parameterMappings = boundSql.getParameterMappings(); if (parameterMappings != null) { Configuration configuration = mappedStatement.getConfiguration(); TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry(); MetaObject metaObject = parameterObject == null ? null : configuration.newMetaObject(parameterObject); for (int i = 0; i < parameterMappings.size(); i++) { ParameterMapping parameterMapping = parameterMappings.get(i); if (parameterMapping.getMode() != ParameterMode.OUT) { Object value; String propertyName = parameterMapping.getProperty(); PropertyTokenizer prop = new PropertyTokenizer(propertyName); if (parameterObject == null) { value = null; } else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) { value = parameterObject; } else if (boundSql.hasAdditionalParameter(propertyName)) { value = boundSql.getAdditionalParameter(propertyName); } else if (propertyName.startsWith(ForEachSqlNode.ITEM_PREFIX) && boundSql.hasAdditionalParameter(prop.getName())) { value = boundSql.getAdditionalParameter(prop.getName()); if (value != null) { value = configuration.newMetaObject(value) .getValue(propertyName.substring(prop.getName().length())); } } else { value = metaObject == null ? null : metaObject.getValue(propertyName); } TypeHandler typeHandler = parameterMapping.getTypeHandler(); if (typeHandler == null) { throw new ExecutorException("There was no TypeHandler found for parameter " + propertyName + " of statement " + mappedStatement.getId()); } typeHandler.setParameter(ps, i + 1, value, parameterMapping.getJdbcType()); } } } }
From source file:jp.co.ctc_g.jfw.core.jdbc.mybatis.CallableQueryBuilder.java
License:Apache License
@Override protected List<Object> createParameterList(QueryInformation queryLoggingSource) { List<Object> parameterList = new ArrayList<Object>(); for (ParameterMapping p : queryLoggingSource.getParameterMappingList()) { String propertyName = p.getProperty(); PropertyTokenizer prop = new PropertyTokenizer(propertyName); if (p.getMode() != ParameterMode.OUT) { Object parameterObject = queryLoggingSource.getParameterObject(); if (parameterObject == null) { parameterList.add(null); } else if (queryLoggingSource.getTypeHandlerRegistry().hasTypeHandler(parameterObject.getClass())) { parameterList.add(parameterObject); } else if (queryLoggingSource.getBoundSql().hasAdditionalParameter(propertyName)) { parameterList.add(queryLoggingSource.getBoundSql().getAdditionalParameter(propertyName)); } else if (propertyName.startsWith(ForEachSqlNode.ITEM_PREFIX) && queryLoggingSource.getBoundSql().hasAdditionalParameter(prop.getName())) { String value = queryLoggingSource.getBoundSql().getAdditionalParameter(prop.getName()) .toString();/* ww w . jav a2 s.co m*/ if (value != null) { Object obj = queryLoggingSource.getMetaObject() .getValue(propertyName.substring(prop.getName().length())); parameterList.add(obj == null ? null : obj); } else { parameterList.add(null); } } else { Object obj = queryLoggingSource.getMetaObject() == null ? null : queryLoggingSource.getMetaObject().getValue(propertyName); parameterList.add(obj == null ? null : obj); } } else { parameterList.add(propertyName); } } return parameterList; }
From source file:jp.co.ctc_g.jfw.core.jdbc.mybatis.PreparedQueryBuilder.java
License:Apache License
@Override protected List<Object> createParameterList(QueryInformation queryLoggingSource) { List<Object> parameterList = new ArrayList<Object>(); for (ParameterMapping p : queryLoggingSource.getParameterMappingList()) { String propertyName = p.getProperty(); PropertyTokenizer prop = new PropertyTokenizer(propertyName); if (p.getMode() != ParameterMode.OUT) { Object parameterObject = queryLoggingSource.getParameterObject(); if (parameterObject == null) { parameterList.add(null); } else if (queryLoggingSource.getTypeHandlerRegistry().hasTypeHandler(parameterObject.getClass())) { parameterList.add(parameterObject); } else if (queryLoggingSource.getBoundSql().hasAdditionalParameter(propertyName)) { parameterList.add(queryLoggingSource.getBoundSql().getAdditionalParameter(propertyName)); } else if (propertyName.startsWith(ForEachSqlNode.ITEM_PREFIX) && queryLoggingSource.getBoundSql().hasAdditionalParameter(prop.getName())) { String value = queryLoggingSource.getBoundSql().getAdditionalParameter(prop.getName()) .toString();/*from ww w . j a v a 2s .co m*/ if (value != null) { Object obj = queryLoggingSource.getMetaObject() .getValue(propertyName.substring(prop.getName().length())); parameterList.add(obj == null ? null : obj); } else { parameterList.add(null); } } else { Object obj = queryLoggingSource.getMetaObject() == null ? null : queryLoggingSource.getMetaObject().getValue(propertyName); parameterList.add(obj == null ? null : obj); } } } return parameterList; }