You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/06/05 04:47:30 UTC
[GitHub] [shardingsphere] AzeWZ opened a new issue, #18178: Shardingsphere-jdbc single db , how to config local transaction with spring
AzeWZ opened a new issue, #18178:
URL: https://github.com/apache/shardingsphere/issues/18178
## Question
prepare:
1. single db, only use partition table function
2. with spring boot
3. don't use xa or seata. i only have one db.
q:
transaction don't rollback. however config
" data-source-properties:
useLocalSessionState: false" can rollback.
how to config transaction with spring boot.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] RaigorJiang commented on issue #18178: Shardingsphere-jdbc single db , how to config local transaction with spring
Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #18178:
URL: https://github.com/apache/shardingsphere/issues/18178#issuecomment-1146813117
Hi @jingshanglu , can you take a look at this question?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] AzeWZ closed issue #18178: Shardingsphere-jdbc single db , how to config local transaction with spring
Posted by GitBox <gi...@apache.org>.
AzeWZ closed issue #18178: Shardingsphere-jdbc single db , how to config local transaction with spring
URL: https://github.com/apache/shardingsphere/issues/18178
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] phdbutbachelor commented on issue #18178: Shardingsphere-jdbc single db , how to config local transaction with spring
Posted by GitBox <gi...@apache.org>.
phdbutbachelor commented on issue #18178:
URL: https://github.com/apache/shardingsphere/issues/18178#issuecomment-1148164639
you can inject a ShardingSphereDataSource bean into a LocalSesstionFactoryBean, then a PlatformTransactionManager:
-----------------------------------------------------------------------------------------------------------------------------------
@Bean
public DataSource mainShardingSphereDataSource() throws IOException, SQLException {
File _yaml = ResourceUtils.getFile("classpath:shardingsphere.yml");
return YamlShardingSphereDataSourceFactory.createDataSource(_yaml);
}
@Bean
public LocalSessionFactoryBean mainShardingSphereSessionFactory(@Value(value = "${spring.datasource.main.dialect}") String dialect, @Qualifier(value = "mainShardingSphereDataSource") DataSource dataSource) {
LocalSessionFactoryBean _localSessionFactoryBean = new LocalSessionFactoryBean();
_localSessionFactoryBean.setDataSource(dataSource);
_localSessionFactoryBean.setPackagesToScan("gmcc.sparrow.model.set");
Properties _properties = new Properties();
_properties.setProperty("hibernate.dialect", dialect); // 设置方言
_localSessionFactoryBean.setHibernateProperties(_properties);
return _localSessionFactoryBean;
}
@Bean
public PlatformTransactionManager mainShardingSphereTransactionManager(@Qualifier(value = "mainShardingSphereSessionFactory") EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
}
-----------------------------------------------------------------------------------------------------------------------------------
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org