Skip to content

Change to Variable-length argument from array argument on SqlSessionFactoryBean #380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public void setCache(Cache cache) {
* list of plugins
*
*/
public void setPlugins(Interceptor[] plugins) {
public void setPlugins(Interceptor... plugins) {
this.plugins = plugins;
}

Expand Down Expand Up @@ -289,7 +289,7 @@ public void setTypeHandlersPackage(String typeHandlersPackage) {
* @param typeHandlers
* Type handler list
*/
public void setTypeHandlers(TypeHandler<?>[] typeHandlers) {
public void setTypeHandlers(TypeHandler<?>... typeHandlers) {
this.typeHandlers = typeHandlers;
}

Expand All @@ -301,7 +301,7 @@ public void setTypeHandlers(TypeHandler<?>[] typeHandlers) {
* @param typeAliases
* Type aliases list
*/
public void setTypeAliases(Class<?>[] typeAliases) {
public void setTypeAliases(Class<?>... typeAliases) {
this.typeAliases = typeAliases;
}

Expand Down Expand Up @@ -351,7 +351,7 @@ public void setConfiguration(Configuration configuration) {
* @param mapperLocations
* location of MyBatis mapper files
*/
public void setMapperLocations(Resource[] mapperLocations) {
public void setMapperLocations(Resource... mapperLocations) {
this.mapperLocations = mapperLocations;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public abstract class AbstractMyBatisSpringTest {
public static void setupBase() throws Exception {
// create an SqlSessionFactory that will use SpringManagedTransactions
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
factoryBean.setMapperLocations(new Resource[] { new ClassPathResource("org/mybatis/spring/TestMapper.xml") });
factoryBean.setMapperLocations(new ClassPathResource("org/mybatis/spring/TestMapper.xml"));
// note running without SqlSessionFactoryBean.configLocation set => default configuration
factoryBean.setDataSource(dataSource);
factoryBean.setPlugins(new Interceptor[] { executorInterceptor });
factoryBean.setPlugins(executorInterceptor);

exceptionTranslator = new MyBatisExceptionTranslator(dataSource, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void testSpecifyConfigurationAndConfigLocation() throws Exception {
void testFragmentsAreReadWithMapperLocations() throws Exception {
setupFactoryBean();

factoryBean.setMapperLocations(new Resource[] { new ClassPathResource("org/mybatis/spring/TestMapper.xml") });
factoryBean.setMapperLocations(new ClassPathResource("org/mybatis/spring/TestMapper.xml"));

SqlSessionFactory factory = factoryBean.getObject();

Expand All @@ -321,7 +321,7 @@ void testNullMapperLocations() throws Exception {
@Test
void testEmptyMapperLocations() throws Exception {
setupFactoryBean();
factoryBean.setMapperLocations(new org.springframework.core.io.Resource[0]);
factoryBean.setMapperLocations();

assertDefaultConfig(factoryBean.getObject());
}
Expand All @@ -337,7 +337,7 @@ void testMapperLocationsWithNullEntry() throws Exception {
@Test
void testAddATypeHandler() throws Exception {
setupFactoryBean();
factoryBean.setTypeHandlers(new TypeHandler[] { new DummyTypeHandler() });
factoryBean.setTypeHandlers(new DummyTypeHandler());

TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry();
assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue();
Expand All @@ -347,7 +347,7 @@ void testAddATypeHandler() throws Exception {
void testAddATypeAlias() throws Exception {
setupFactoryBean();

factoryBean.setTypeAliases(new Class[] { DummyTypeAlias.class });
factoryBean.setTypeAliases(DummyTypeAlias.class);
TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry();
typeAliasRegistry.resolveAlias("testAlias");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void testAddToConfigTrue() throws Exception {
factoryBean.setDatabaseIdProvider(null);
// mapperLocations properties defaults to null
factoryBean.setDataSource(dataSource);
factoryBean.setPlugins(new Interceptor[] { executorInterceptor });
factoryBean.setPlugins(executorInterceptor);

SqlSessionFactory sqlSessionFactory = factoryBean.getObject();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public PlatformTransactionManager transactionalManager() {
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean ss = new SqlSessionFactoryBean();
ss.setDataSource(dataSource());
ss.setMapperLocations(new Resource[] { new ClassPathResource("org/mybatis/spring/sample/mapper/UserMapper.xml") });
ss.setMapperLocations(new ClassPathResource("org/mybatis/spring/sample/mapper/UserMapper.xml"));
return ss.getObject();
}

Expand Down