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/11/24 10:20:11 UTC
[GitHub] [shardingsphere] dbin0123 opened a new issue, #22387: rewrite sql to lose the schema
dbin0123 opened a new issue, #22387:
URL: https://github.com/apache/shardingsphere/issues/22387
database: dm8
sharding version: 5.2.1
org.apache.shardingsphere.infra.rewrite.sql.impl.AbstractSQLBuilder.toSQL()
![image](https://user-images.githubusercontent.com/18297300/203758724-3b255b1b-e4c6-4721-aca6-df2b98de54e8.png)
--
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] strongduanmu commented on issue #22387: rewrite sql to lose the schema
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #22387:
URL: https://github.com/apache/shardingsphere/issues/22387#issuecomment-1328527874
@dbin0123 Can you provide your configuration to help reproduce this exception?
--
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] RaigorJiang commented on issue #22387: rewrite sql to lose the schema
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on issue #22387:
URL: https://github.com/apache/shardingsphere/issues/22387#issuecomment-1407268524
Closed due to no response.
If this problem persists, please reopen it or submit a new one.
--
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] dbin0123 commented on issue #22387: rewrite sql to lose the schema
Posted by GitBox <gi...@apache.org>.
dbin0123 commented on issue #22387:
URL: https://github.com/apache/shardingsphere/issues/22387#issuecomment-1329935818
The example configuration obtains the data source'getDataSource()'. There is a problem with the data source name, please adjust it to`healthcloud_platform_support`. Thank you
--
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] dbin0123 commented on issue #22387: rewrite sql to lose the schema
Posted by GitBox <gi...@apache.org>.
dbin0123 commented on issue #22387:
URL: https://github.com/apache/shardingsphere/issues/22387#issuecomment-1329935843
The example configuration obtains the data source'getDataSource()'. There is a problem with the data source name, please adjust it to`healthcloud_platform_support`. Thank you
--
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] RaigorJiang closed issue #22387: rewrite sql to lose the schema
Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang closed issue #22387: rewrite sql to lose the schema
URL: https://github.com/apache/shardingsphere/issues/22387
--
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] dbin0123 commented on issue #22387: rewrite sql to lose the schema
Posted by GitBox <gi...@apache.org>.
dbin0123 commented on issue #22387:
URL: https://github.com/apache/shardingsphere/issues/22387#issuecomment-1329309709
##### spring config
`
@Slf4j
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = {"com.example.demo.dao.repository"})
public class JPAConfig {
@Primary
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(@Qualifier("dataSource") DataSource dataSource) {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource);
em.setPackagesToScan("com.example.demo.dao.entity");
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
em.setJpaProperties(additionalProperties());
return em;
}
private Properties additionalProperties() {
Properties properties = new Properties();
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.DmDialect");
return properties;
}
@Primary
@Bean(name = "transactionManager")
public JpaTransactionManager transactionManager(@Qualifier("entityManagerFactory") LocalContainerEntityManagerFactoryBean entityManagerFactory) {
JpaTransactionManager manager = new JpaTransactionManager();
manager.setEntityManagerFactory(entityManagerFactory.getObject());
return manager;
}
@Primary
@Bean(name = "dataSource")
public DataSource dataSource() throws SQLException {
//全局是否保存明文字段
Boolean shardingSavePlain = Boolean.FALSE;
//使用加密字段查询
Boolean queryWithCipherColumn = Boolean.TRUE;
//分表, 加密, 读写分离等配置
List<RuleConfiguration> listShardingRuleConfig = new ArrayList<>();
//数据源
String dataSourceName = "healthcloud_platform_support";
Map<String, DataSource> dataSourceMap = new HashMap<>(1);
dataSourceMap.put(dataSourceName, getDataSource());
log.info("代理数据源名称:{}, 使用加密字段查询:{},是否保存明文字段:{}, 初始化加密字段信息...开始...", dataSourceName, queryWithCipherColumn, shardingSavePlain);
//表, 字段加密配置
Map<String, List<EncryptColumnRuleConfiguration>> listEncryptTableMap = new HashMap<>();
//是否使用密码列查询 默认true
//逻辑列, 加密类, HASH列, 明文列
listEncryptTableMap.put("tb_sharding_encrypt", Arrays.asList(
new EncryptColumnRuleConfiguration("name", "name_e", "name_m", null, "AES", "MD5", true)));
//表字段加密信息
List<EncryptTableRuleConfiguration> listEncryptTableRule = new ArrayList<>();
for (Map.Entry<String, List<EncryptColumnRuleConfiguration>> encryptColumnRuleEntry : listEncryptTableMap.entrySet()) {
listEncryptTableRule.add(new EncryptTableRuleConfiguration(encryptColumnRuleEntry.getKey(), encryptColumnRuleEntry.getValue(), queryWithCipherColumn));
}
//加密配置
Map<String, AlgorithmConfiguration> encryptorsMap = new HashMap<>(2);
Properties aesProperties = new Properties();
aesProperties.setProperty("aes-key-value", "12345");
encryptorsMap.put("AES", new AlgorithmConfiguration("AES", aesProperties));
encryptorsMap.put("MD5", new AlgorithmConfiguration("MD5", new Properties()));
//表名称, 字段加密信息
listShardingRuleConfig.add(new EncryptRuleConfiguration(listEncryptTableRule, encryptorsMap, queryWithCipherColumn));
log.info("代理数据源名称:{}, 使用加密字段查询:{}, 初始化数据分片配置在...开始...", dataSourceName, queryWithCipherColumn);
try {
Class.forName("org.h2.Driver");
} catch (ClassNotFoundException e) {
}
ModeConfiguration modeConfiguration = new ModeConfiguration("Standalone", new StandalonePersistRepositoryConfiguration("JDBC", new Properties()));
Properties properties = new Properties();
properties.put("sql-show", true);
properties.put("sharding-save-plain", shardingSavePlain);
properties.put("query-with-cipher-column", queryWithCipherColumn);
return ShardingSphereDataSourceFactory.createDataSource(dataSourceName, modeConfiguration, dataSourceMap, listShardingRuleConfig, new Properties());
}
public DataSource getDataSource() throws SQLException {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName("dm.jdbc.driver.DmDriver");
dataSource.setUrl("jdbc:dm://127.0.0.1:5236/test?characterEncoding=utf-8&useSSL=false");
dataSource.setUsername("sys_dev");
dataSource.setPassword("123456");
dataSource.setInitialSize(10);
dataSource.setMinIdle(1);
dataSource.setMaxActive(2000);
dataSource.setMaxWait(60000L);
dataSource.setTimeBetweenEvictionRunsMillis(60000L);
dataSource.setMinEvictableIdleTimeMillis(300000L);
dataSource.setValidationQuery("SELECT 1");
dataSource.setTestWhileIdle(true);
dataSource.setTestOnBorrow(true);
dataSource.setTestOnReturn(false);
return dataSource;
}
}
`
@strongduanmu
--
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] RaigorJiang commented on issue #22387: rewrite sql to lose the schema
Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #22387:
URL: https://github.com/apache/shardingsphere/issues/22387#issuecomment-1386503051
Hi @dbin0123
Has this issue been resolved?
In addition, the ShardingSphere community does not have a test environment for the DM database and cannot verify your scenario.
--
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