本文整理汇总了Java中org.apache.ibatis.binding.BindingException类的典型用法代码示例。如果您正苦于以下问题:Java BindingException类的具体用法?Java BindingException怎么用?Java BindingException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BindingException类属于org.apache.ibatis.binding包,在下文中一共展示了BindingException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSqlSourceFromAnnotations
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) {
try {
Class<? extends Annotation> sqlAnnotationType = getSqlAnnotationType(method);
Class<? extends Annotation> sqlProviderAnnotationType = getSqlProviderAnnotationType(method);
if (sqlAnnotationType != null) {
if (sqlProviderAnnotationType != null) {
throw new BindingException("You cannot supply both a static SQL and SqlProvider to method named " + method.getName());
}
Annotation sqlAnnotation = method.getAnnotation(sqlAnnotationType);
final String[] strings = (String[]) sqlAnnotation.getClass().getMethod("value").invoke(sqlAnnotation);
return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
} else if (sqlProviderAnnotationType != null) {
Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation);
}
return null;
} catch (Exception e) {
throw new BuilderException("Could not find value method on SQL annotation. Cause: " + e, e);
}
}
示例2: getMapper
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
@Override
public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
for (SqlSessionFactory sqlSessionFactory : getSqlSessionFactories()) {
T mapper = null;
try {
mapper = sqlSessionFactory.getConfiguration().getMapper(type, sqlSession);
} catch (BindingException e) {
// ignore exception
}
if (mapper != null) {
return mapper;
}
}
throw new BindingException("Type " + type + " is not known to the MapperRegistry.");
}
示例3: getMappedStatement
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
@Override
public MappedStatement getMappedStatement(String id) {
Exception exception = null;
MappedStatement mappedStatement = null;
for (SqlSessionFactory sqlSessionFactory : getSqlSessionFactories()) {
try {
mappedStatement = sqlSessionFactory.getConfiguration().getMappedStatement(id);
} catch (Exception e) {
// ignore exception
exception = e;
}
if (mappedStatement != null) {
return mappedStatement;
}
}
throw new BindingException("Invalid bound statement (not found): " + id, exception);
}
示例4: getHotDownloadCount
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
@Override
public long getHotDownloadCount(short catalog, Integer subCatalog, Integer noAds, Integer noVirus, Integer official) {
Assert.isTrue(catalog > 0, "catalog negative!");
if (subCatalog != null) {
Assert.isTrue(subCatalog > -1, "date negative!");
}
Boolean bNoAds = null, bOfficial = null;
if (noAds != null && noAds.intValue() == 1) {
bNoAds = Boolean.TRUE;
}
if (official != null && official.intValue() == 1) {
bOfficial = Boolean.TRUE;
}
long lg = 0;
try {
lg = appMapper.countByFilters(catalog, subCatalog, bNoAds, bOfficial);
} catch (BindingException e) {
logger.error("BindingException" + e);
}
return lg;
}
示例5: getSqlSourceFromAnnotations
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) {
try {
Class<? extends Annotation> sqlAnnotationType = getSqlAnnotationType(method);
Class<? extends Annotation> sqlProviderAnnotationType = getSqlProviderAnnotationType(method);
if (sqlAnnotationType != null) {
if (sqlProviderAnnotationType != null) {
throw new BindingException("You cannot supply both a static SQL and SqlProvider to method named " + method.getName());
}
Annotation sqlAnnotation = method.getAnnotation(sqlAnnotationType);
final String[] strings = (String[]) sqlAnnotation.getClass().getMethod("value").invoke(sqlAnnotation);
return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
} else if (sqlProviderAnnotationType != null) {
Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation);
}
return null;
} catch (Exception e) {
throw new BuilderException("Could not find value method on SQL annotation. Cause: " + e, e);
}
}
示例6: shouldInstantiateAndThrowAllCustomExceptions
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
@Test
public void shouldInstantiateAndThrowAllCustomExceptions() throws Exception {
Class<?>[] exceptionTypes = {
BindingException.class,
CacheException.class,
DataSourceException.class,
ExecutorException.class,
LogException.class,
ParsingException.class,
BuilderException.class,
PluginException.class,
ReflectionException.class,
PersistenceException.class,
SqlSessionException.class,
TransactionException.class,
TypeException.class,
ScriptingException.class
};
for (Class<?> exceptionType : exceptionTypes) {
testExceptionConstructors(exceptionType);
}
}
示例7: execute
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
/**
* 代理执行方法。
*
* @param args 参数信息
* @return 执行结果
*/
@SuppressWarnings("unchecked")
public Object execute(Object[] args) {
final Object param = getParam(args);
Page<Object> page;
RowBounds rowBounds;
if (paginationIndex != null) {
page = (Page<Object>) args[paginationIndex];
rowBounds = new RowBounds(page.getFirstResult(), page.getMaxResults());
} else if (rowBoundsIndex != null) {
rowBounds = (RowBounds) args[rowBoundsIndex];
page = new Page<Object>();
} else {
throw new BindingException("Invalid bound statement (not found rowBounds or pagination in paramenters)");
}
page.setCount(executeForCount(param));
page.setList(executeForList(param, rowBounds));
return page;
}
示例8: invoke
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
if (isObjectMethod(method)) {
return null;
}
final Class<?> declaringInterface = findDeclaringInterface(proxy, method);
if (Page.class.isAssignableFrom(method.getReturnType())) {
// 分页处理
return new PaginationMapperMethod(declaringInterface, method, sqlSession).execute(args);
}
// 原处理方式
final MapperMethod mapperMethod = new MapperMethod(declaringInterface, method, sqlSession.getConfiguration());
final Object result = mapperMethod.execute(sqlSession, args);
if (result == null && method.getReturnType().isPrimitive()) {
throw new BindingException(
"Mapper method '"
+ method.getName()
+ "' ("
+ method.getDeclaringClass()
+ ") attempted to return null from a method with a primitive return type ("
+ method.getReturnType() + ").");
}
return result;
}
示例9: findDeclaringInterface
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
private Class<?> findDeclaringInterface(Object proxy, Method method) {
Class<?> declaringInterface = null;
for (Class<?> mapperFaces : proxy.getClass().getInterfaces()) {
Method m = Reflections.getAccessibleMethod(mapperFaces,
method.getName(),
method.getParameterTypes());
if (m != null) {
declaringInterface = mapperFaces;
}
}
if (declaringInterface == null) {
throw new BindingException(
"Could not find interface with the given method " + method);
}
return declaringInterface;
}
示例10: getSqlSourceFromAnnotations
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) {
try {
Class<? extends Annotation> sqlAnnotationType = getSqlAnnotationType(method);
Class<? extends Annotation> sqlProviderAnnotationType = getSqlProviderAnnotationType(method);
if (sqlAnnotationType != null) {
if (sqlProviderAnnotationType != null) {
throw new BindingException("You cannot supply both a static SQL and SqlProvider to method named " + method.getName());
}
Annotation sqlAnnotation = method.getAnnotation(sqlAnnotationType);
final String[] strings = (String[]) sqlAnnotation.getClass().getMethod("value").invoke(sqlAnnotation);
return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
} else if (sqlProviderAnnotationType != null) {
Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation, type, method);
}
return null;
} catch (Exception e) {
throw new BuilderException("Could not find value method on SQL annotation. Cause: " + e, e);
}
}
示例11: execute
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
/**
* 代理执行方法。
*
* @param args
* 参数信息
* @return 执行结果
*/
public Object execute(Object[] args) {
final Object param = getParam(args);
Pagination<Object> page;
RowBounds rowBounds;
if (null != paginationIndex) {
page = (Pagination) args[paginationIndex];
rowBounds = new RowBounds(page.getOffset(), page.getLimit());
} else if (null != rowBoundsIndex) {
rowBounds = (RowBounds) args[rowBoundsIndex];
page = new Pagination<Object>();
} else {
throw new BindingException(
"Invalid bound statement (not found rowBounds or pagination in paramenters)");
}
page.setTotal(executeForCount(param));
page.setDatas(executeForList(param, rowBounds));
return page;
}
示例12: getSqlSourceFromAnnotations
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) {
try {
Class<? extends Annotation> sqlAnnotationType = getSqlAnnotationType(method);
Class<? extends Annotation> sqlProviderAnnotationType = getSqlProviderAnnotationType(method);
if (sqlAnnotationType != null) {
if (sqlProviderAnnotationType != null) {
throw new BindingException("You cannot supply both a static SQL and SqlProvider to method named " + method.getName());
}
Annotation sqlAnnotation = method.getAnnotation(sqlAnnotationType);
final String[] strings = (String[]) sqlAnnotation.getClass().getMethod("value").invoke(sqlAnnotation);
return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
} else if (sqlProviderAnnotationType != null) {
Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation, type, method);
}
return null;
} catch (Exception e) {
throw new BuilderException("Could not find value method on SQL annotation. Cause: " + e, e);
}
}
示例13: getTypeHandlers
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
private TypeHandler<?>[] getTypeHandlers(TypeHandlerRegistry typeHandlerRegistry, MetaObject metaParam, String[] keyProperties, ResultSetMetaData rsmd) throws SQLException {
TypeHandler<?>[] typeHandlers = new TypeHandler<?>[keyProperties.length];
for (int i = 0; i < keyProperties.length; i++) {
if (metaParam.hasSetter(keyProperties[i])) {
TypeHandler<?> th;
try {
Class<?> keyPropertyType = metaParam.getSetterType(keyProperties[i]);
th = typeHandlerRegistry.getTypeHandler(keyPropertyType, JdbcType.forCode(rsmd.getColumnType(i + 1)));
} catch (BindingException e) {
th = null;
}
typeHandlers[i] = th;
}
}
return typeHandlers;
}
示例14: getMapper
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
@Override
public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
if (!hasMapper(type)) {
throw new BindingException("Type " + type
+ " is not known to the MapperRegistry.");
}
try {
return PaginationMapperProxy.newMapperProxy(type, sqlSession);
} catch (Exception e) {
throw new BindingException("Error getting mapper instance. Cause: "
+ e, e);
}
}
示例15: setupCommandType
import org.apache.ibatis.binding.BindingException; //导入依赖的package包/类
/**
* 设置当前的参数的类型信息
*/
private void setupCommandType() {
MappedStatement ms = config.getMappedStatement(commandName);
type = ms.getSqlCommandType();
if (type != SqlCommandType.SELECT) {
throw new BindingException("Unsupport execution method for: "
+ commandName);
}
}