spring icon indicating copy to clipboard operation
spring copied to clipboard

SqlSessionDaoSupport create dozens of SqlSessionTemplate instances meaningless

Open yywmrz opened this issue 3 years ago • 2 comments

According to the spring #populateBean method injecting properties' order, reorder the #setSqlSessionTemplate and #setSqlSessionFactory methods postion. Currently, #setSqlSessionFactory method be invoked before #setSqlSessionTemplate ,it will create SqlSessionTemplate meaningless, because the #setSqlSessionTemplate will override the instance the #setSqlSessionFactory method created .This #createSqlSessionTemplate method will be invoked dozens of times meaningless. It will create dozens of SqlSessionTemplate instances.

yywmrz avatar Mar 11 '21 03:03 yywmrz

Coverage Status

Coverage remained the same at 89.367% when pulling c4d70186fa373bb531a09cda16bbbc454d1cc31a on yywmrz:master into 477a4f5078f2cecb5d50cb964071310d22036c59 on mybatis:master.

coveralls avatar Mar 11 '21 03:03 coveralls

it created sqlSessionTemplate instance in the spring container ,the MapperFactorybean still created dozens of SqlSessionTemplate instances meaningless cause of the order setter proterties (setSqlSessionFactory, setSqlSessionTemplate )

@Bean
  @ConditionalOnMissingBean
  public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
    ExecutorType executorType = this.properties.getExecutorType();
    if (executorType != null) {
      return new SqlSessionTemplate(sqlSessionFactory, executorType);
    } else {
      return new SqlSessionTemplate(sqlSessionFactory);
    }
  }

yywmrz avatar Mar 11 '21 04:03 yywmrz

closing as this doesn't fix anything, is out of date, and sounds more like an issue.

hazendaz avatar Sep 07 '22 22:09 hazendaz