/** * Gets the DatabaseIdProvider * * @since 1.1.0 * @return a specified DatabaseIdProvider */ public DatabaseIdProvider getDatabaseIdProvider() { return databaseIdProvider; }
/** * Sets the DatabaseIdProvider. As of version 1.2.2 this variable is not initialized by default. * * @since 1.1.0 * @param databaseIdProvider * a DatabaseIdProvider */ publicvoidsetDatabaseIdProvider(DatabaseIdProvider databaseIdProvider) { this.databaseIdProvider = databaseIdProvider; }
/** * Gets the VFS. * * @return a specified VFS */ public Class<? extendsVFS> getVfs() { returnthis.vfs; }
/** * Packages to search for type aliases. * * <p> * Since 2.0.1, allow to specify a wildcard such as {@code com.example.*.model}. * * @since 1.0.1 * * @param typeAliasesPackage * package to scan for domain objects * */ publicvoidsetTypeAliasesPackage(String typeAliasesPackage) { this.typeAliasesPackage = typeAliasesPackage; }
/** * Super class which domain objects have to extend to have a type alias created. No effect if there is no package to * scan configured. * * @since 1.1.2 * * @param typeAliasesSuperType * super class for domain objects * */ publicvoidsetTypeAliasesSuperType(Class<?> typeAliasesSuperType) { this.typeAliasesSuperType = typeAliasesSuperType; }
/** * Packages to search for type handlers. * * <p> * Since 2.0.1, allow to specify a wildcard such as {@code com.example.*.typehandler}. * * @since 1.0.1 * * @param typeHandlersPackage * package to scan for type handlers * */ publicvoidsetTypeHandlersPackage(String typeHandlersPackage) { this.typeHandlersPackage = typeHandlersPackage; }
/** * Set type handlers. They must be annotated with {@code MappedTypes} and optionally with {@code MappedJdbcTypes} * * @since 1.0.1 * * @param typeHandlers * Type handler list */ publicvoidsetTypeHandlers(TypeHandler<?>... typeHandlers) { this.typeHandlers = typeHandlers; }
/** * Set the default type handler class for enum. * * @since 2.0.5 * @param defaultEnumTypeHandler * The default type handler class for enum */ publicvoidsetDefaultEnumTypeHandler( @SuppressWarnings("rawtypes") Class<? extends TypeHandler> defaultEnumTypeHandler) { this.defaultEnumTypeHandler = defaultEnumTypeHandler; }
/** * List of type aliases to register. They can be annotated with {@code Alias} * * @since 1.0.1 * * @param typeAliases * Type aliases list */ publicvoidsetTypeAliases(Class<?>... typeAliases) { this.typeAliases = typeAliases; }
/** * If true, a final check is done on Configuration to assure that all mapped statements are fully loaded and there is * no one still pending to resolve includes. Defaults to false. * * @since 1.0.1 * * @param failFast * enable failFast */ publicvoidsetFailFast(boolean failFast) { this.failFast = failFast; }
/** * Set the location of the MyBatis {@code SqlSessionFactory} config file. A typical value is * "WEB-INF/mybatis-configuration.xml". * * @param configLocation * a location the MyBatis config file */ publicvoidsetConfigLocation(Resource configLocation) { this.configLocation = configLocation; }
/** * Set locations of MyBatis mapper files that are going to be merged into the {@code SqlSessionFactory} configuration * at runtime. * * This is an alternative to specifying "<sqlmapper>" entries in an MyBatis config file. This property being * based on Spring's resource abstraction also allows for specifying resource patterns here: e.g. * "classpath*:sqlmap/*-mapper.xml". * * @param mapperLocations * location of MyBatis mapper files */ publicvoidsetMapperLocations(Resource... mapperLocations) { this.mapperLocations = mapperLocations; }
/** * Set optional properties to be passed into the SqlSession configuration, as alternative to a * {@code <properties>} tag in the configuration xml file. This will be used to resolve placeholders in the * config file. * * @param sqlSessionFactoryProperties * optional properties for the SqlSessionFactory */ publicvoidsetConfigurationProperties(Properties sqlSessionFactoryProperties) { this.configurationProperties = sqlSessionFactoryProperties; }
/** * Set the JDBC {@code DataSource} that this instance should manage transactions for. The {@code DataSource} should * match the one used by the {@code SqlSessionFactory}: for example, you could specify the same JNDI DataSource for * both. * * A transactional JDBC {@code Connection} for this {@code DataSource} will be provided to application code accessing * this {@code DataSource} directly via {@code DataSourceUtils} or {@code DataSourceTransactionManager}. * * The {@code DataSource} specified here should be the target {@code DataSource} to manage transactions for, not a * {@code TransactionAwareDataSourceProxy}. Only data access code may work with * {@code TransactionAwareDataSourceProxy}, while the transaction manager needs to work on the underlying target * {@code DataSource}. If there's nevertheless a {@code TransactionAwareDataSourceProxy} passed in, it will be * unwrapped to extract its target {@code DataSource}. * * @param dataSource * a JDBC {@code DataSource} * */ publicvoidsetDataSource(DataSource dataSource) { if (dataSource instanceof TransactionAwareDataSourceProxy) { // If we got a TransactionAwareDataSourceProxy, we need to perform // transactions for its underlying target DataSource, else data // access code won't see properly exposed transactions (i.e. // transactions for the target DataSource). this.dataSource = ((TransactionAwareDataSourceProxy) dataSource).getTargetDataSource(); } else { this.dataSource = dataSource; } }
/** * Sets the {@code SqlSessionFactoryBuilder} to use when creating the {@code SqlSessionFactory}. * * This is mainly meant for testing so that mock SqlSessionFactory classes can be injected. By default, * {@code SqlSessionFactoryBuilder} creates {@code DefaultSqlSessionFactory} instances. * * @param sqlSessionFactoryBuilder * a SqlSessionFactoryBuilder * */ publicvoidsetSqlSessionFactoryBuilder(SqlSessionFactoryBuilder sqlSessionFactoryBuilder) { this.sqlSessionFactoryBuilder = sqlSessionFactoryBuilder; }
/** * Set the MyBatis TransactionFactory to use. Default is {@code SpringManagedTransactionFactory} * * The default {@code SpringManagedTransactionFactory} should be appropriate for all cases: be it Spring transaction * management, EJB CMT or plain JTA. If there is no active transaction, SqlSession operations will execute SQL * statements non-transactionally. * * <b>It is strongly recommended to use the default {@code TransactionFactory}.</b> If not used, any attempt at * getting an SqlSession through Spring's MyBatis framework will throw an exception if a transaction is active. * * @see SpringManagedTransactionFactory * @param transactionFactory * the MyBatis TransactionFactory */ publicvoidsetTransactionFactory(TransactionFactory transactionFactory) { this.transactionFactory = transactionFactory; }
/** * <b>NOTE:</b> This class <em>overrides</em> any {@code Environment} you have set in the MyBatis config file. This is * used only as a placeholder name. The default value is {@code SqlSessionFactoryBean.class.getSimpleName()}. * * @param environment * the environment name */ publicvoidsetEnvironment(String environment) { this.environment = environment; }
/** * Set scripting language drivers. * * @param scriptingLanguageDrivers * scripting language drivers * @since 2.0.2 */ publicvoidsetScriptingLanguageDrivers(LanguageDriver... scriptingLanguageDrivers) { this.scriptingLanguageDrivers = scriptingLanguageDrivers; }
/** * Set a default scripting language driver class. * * @param defaultScriptingLanguageDriver * A default scripting language driver class * @since 2.0.2 */ publicvoidsetDefaultScriptingLanguageDriver(Class<? extends LanguageDriver> defaultScriptingLanguageDriver) { this.defaultScriptingLanguageDriver = defaultScriptingLanguageDriver; }
/** * {@inheritDoc} */ @Override publicvoidafterPropertiesSet()throws Exception { notNull(dataSource, "Property 'dataSource' is required"); notNull(sqlSessionFactoryBuilder, "Property 'sqlSessionFactoryBuilder' is required"); state((configuration == null && configLocation == null) || !(configuration != null && configLocation != null), "Property 'configuration' and 'configLocation' can not specified with together");