List of usage examples for org.apache.ibatis.builder BuilderException BuilderException
public BuilderException(String message, Throwable cause)
From source file:cc.oit.dao.impl.mybatis.session.XMLConfigBuilder.java
License:Apache License
private void parseConfiguration(XNode root) { try {//from ww w. ja v a 2 s. c o m propertiesElement(root.evalNode("properties")); //issue #117 read properties first typeAliasesElement(root.evalNode("typeAliases")); pluginElement(root.evalNode("plugins")); objectFactoryElement(root.evalNode("objectFactory")); objectWrapperFactoryElement(root.evalNode("objectWrapperFactory")); settingsElement(root.evalNode("settings")); environmentsElement(root.evalNode("environments")); // read it after objectFactory and objectWrapperFactory issue #631 databaseIdProviderElement(root.evalNode("databaseIdProvider")); typeHandlerElement(root.evalNode("typeHandlers")); mapperElement(root.evalNode("mappers")); } catch (Exception e) { throw new BuilderException("Error parsing SQL Mapper Configuration. Cause: " + e, e); } }
From source file:cc.oit.dao.impl.mybatis.session.XMLConfigBuilder.java
License:Apache License
private void typeAliasesElement(XNode parent) { if (parent != null) { for (XNode child : parent.getChildren()) { if ("package".equals(child.getName())) { String typeAliasPackage = child.getStringAttribute("name"); configuration.getTypeAliasRegistry().registerAliases(typeAliasPackage); } else { String alias = child.getStringAttribute("alias"); String type = child.getStringAttribute("type"); try { Class<?> clazz = Resources.classForName(type); if (alias == null) { typeAliasRegistry.registerAlias(clazz); } else { typeAliasRegistry.registerAlias(alias, clazz); }// w w w . j a va 2 s.c o m } catch (ClassNotFoundException e) { throw new BuilderException("Error registering typeAlias for '" + alias + "'. Cause: " + e, e); } } } } }
From source file:com.appleframework.orm.mybatis.pagehelper.sqlsource.PageProviderSqlSource.java
License:Open Source License
/** * 3.3.1?/*w w w. j av a 2s .c om*/ * * @param parameterObject * @return */ private SqlSource createSqlSource331(Object parameterObject) { try { String sql; if (providerTakesParameterObject) { sql = (String) providerMethod.invoke(providerType.newInstance(), parameterObject); } else { sql = (String) providerMethod.invoke(providerType.newInstance()); } Class<?> parameterType = parameterObject == null ? Object.class : parameterObject.getClass(); StaticSqlSource sqlSource = (StaticSqlSource) sqlSourceParser.parse(sql, parameterType, new HashMap<String, Object>()); return new OrderByStaticSqlSource(sqlSource); } catch (Exception e) { throw new BuilderException("Error invoking SqlProvider method (" + providerType.getName() + "." + providerMethod.getName() + "). Cause: " + e, e); } }
From source file:com.baomidou.mybatisplus.MybatisMapperAnnotationBuilder.java
License:Apache License
private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) { try {/* ww w . jav a 2s . c om*/ 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); } }
From source file:com.baomidou.mybatisplus.MybatisXMLConfigBuilder.java
License:Apache License
private void parseConfiguration(XNode root) { try {/*w w w. j av a 2 s .c o m*/ //issue #117 read properties first propertiesElement(root.evalNode("properties")); Properties settings = settingsAsProperties(root.evalNode("settings")); loadCustomVfs(settings); typeAliasesElement(root.evalNode("typeAliases")); pluginElement(root.evalNode("plugins")); objectFactoryElement(root.evalNode("objectFactory")); objectWrapperFactoryElement(root.evalNode("objectWrapperFactory")); reflectorFactoryElement(root.evalNode("reflectorFactory")); settingsElement(settings); // read it after objectFactory and objectWrapperFactory issue #631 environmentsElement(root.evalNode("environments")); databaseIdProviderElement(root.evalNode("databaseIdProvider")); typeHandlerElement(root.evalNode("typeHandlers")); mapperElement(root.evalNode("mappers")); } catch (Exception e) { throw new BuilderException("Error parsing SQL Mapper Configuration. Cause: " + e, e); } }
From source file:com.cetiti.dsp.builder.BaseBuilder.java
License:Apache License
protected JdbcType resolveJdbcType(String alias) { if (alias == null) return null; try {/* w w w . j ava 2 s . c o m*/ return JdbcType.valueOf(alias); } catch (IllegalArgumentException e) { throw new BuilderException("Error resolving JdbcType. Cause: " + e, e); } }
From source file:com.cetiti.dsp.builder.BaseBuilder.java
License:Apache License
protected ResultSetType resolveResultSetType(String alias) { if (alias == null) return null; try {//from w w w . j a v a2 s.c om return ResultSetType.valueOf(alias); } catch (IllegalArgumentException e) { throw new BuilderException("Error resolving ResultSetType. Cause: " + e, e); } }
From source file:com.cetiti.dsp.builder.BaseBuilder.java
License:Apache License
protected ParameterMode resolveParameterMode(String alias) { if (alias == null) return null; try {// w w w .j a va 2s.c o m return ParameterMode.valueOf(alias); } catch (IllegalArgumentException e) { throw new BuilderException("Error resolving ParameterMode. Cause: " + e, e); } }
From source file:com.cetiti.dsp.builder.BaseBuilder.java
License:Apache License
protected Object createInstance(String alias) { Class<?> clazz = resolveClass(alias); if (clazz == null) return null; try {/*from w w w . j a v a2 s . c o m*/ return resolveClass(alias).newInstance(); } catch (Exception e) { throw new BuilderException("Error creating instance. Cause: " + e, e); } }
From source file:com.cetiti.dsp.builder.BaseBuilder.java
License:Apache License
protected Class<?> resolveClass(String alias) { if (alias == null) return null; try {/* w w w.j a v a 2s . c om*/ return resolveAlias(alias); } catch (Exception e) { throw new BuilderException("Error resolving class. Cause: " + e, e); } }