Finally i solved this issue in this way :
1. Added `@EnableTransactionManagement` in Application class and also added
`PlatformTransactionManager` Bean. Check the bellow code:
@Autowired
private EntityManagerFactory entityManagerFactory;
@Bean
public PlatformTransactionManager transactionManager()
{
return new JpaTransactionManager(entityManagerFactory);
}
Here is the imports :
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
2. In my scheduler code added bellow code:
@Scheduled(fixedRate = 60 *10*1000)
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void reportCurrentTime() {
doDatabaseTransaction();
}
Here is the imports :
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
Hope this will solve your problem :)
Finally i solved this issue in this way :
1. Added `@EnableTransactionManagement` in Application class and also added
`PlatformTransactionManager` Bean. Check the bellow code:
> @Autowired
> private EntityManagerFactory entityManagerFactory;
>
> @Bean
> public PlatformTransactionManager transactionManager()
> {
> return new JpaTransactionManager(entityManagerFactory);
> }
Here is the imports :
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
2. In my scheduler code added bellow code:
> @Scheduled(fixedRate = 60 *10*1000)
> @Transactional(propagation=Propagation.REQUIRES_NEW)
> public void reportCurrentTime() {
> doDatabaseTransaction();
> }
Here is the imports :
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
Hope this will solve your problem :)