ncc0706 opened a new issue, #37711:
URL: https://github.com/apache/shardingsphere/issues/37711
## Question
```groovy
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.baomidou:mybatis-plus-spring-boot3-starter")
implementation("com.baomidou:mybatis-plus-extension")
implementation("com.baomidou:mybatis-plus-jsqlparser")
// implementation("org.yaml:snakeyaml:2.2")
implementation("org.apache.shardingsphere:shardingsphere-jdbc:5.5.2")
//implementation("org.apache.derby:derby:10.17.1.0")
//implementation("org.apache.derby:derbytools:10.17.1.0")
runtimeOnly("com.mysql:mysql-connector-j")
// runtimeOnly("com.oracle.database.jdbc:ojdbc11")
// runtimeOnly("org.postgresql:postgresql")
}
```
```xml
<update id="dropTmpTable">
drop temporary table if exists tmp_sys_user
</update>
<update id="createTmpTable">
CREATE TEMPORARY TABLE tmp_sys_user AS SELECT * FROM sys_user WHERE
nickname like 'user%'
</update>
<select id="selectTmpTable" resultType="io.arukas.domain.SysUser">
select * from tmp_sys_user
</select>
```
```java
public final class CreateTableStatementSchemaRefresher implements
MetaDataRefresher<CreateTableStatement> {
public void refresh(MetaDataManagerPersistService
metaDataManagerPersistService, ShardingSphereDatabase database,
Collection<String> logicDataSourceNames, String schemaName, DatabaseType
databaseType, CreateTableStatement sqlStatement, ConfigurationProperties props)
throws SQLException {
String tableName = TableRefreshUtils.getTableName(databaseType,
sqlStatement.getTable().getTableName().getIdentifier());
RuleMetaData ruleMetaData = new RuleMetaData(new
LinkedList(database.getRuleMetaData().getRules()));
boolean isSingleTable = TableRefreshUtils.isSingleTable(tableName,
database);
if (isSingleTable) {
ruleMetaData.getAttributes(MutableDataNodeRuleAttribute.class).forEach((each)
-> each.put((String)logicDataSourceNames.iterator().next(), schemaName,
tableName));
}
GenericSchemaBuilderMaterial material = new
GenericSchemaBuilderMaterial(database.getResourceMetaData().getStorageUnits(),
ruleMetaData.getRules(), props, schemaName);
Map<String, ShardingSphereSchema> schemas =
GenericSchemaBuilder.build(Collections.singletonList(tableName),
database.getProtocolType(), material);
Optional<ShardingSphereTable> actualTableMetaData =
Optional.ofNullable((ShardingSphereSchema)schemas.get(schemaName)).map((optional)
-> optional.getTable(tableName));
Preconditions.checkState(actualTableMetaData.isPresent(), "Load
actual table metadata '%s' failed.", tableName);
metaDataManagerPersistService.createTable(database.getName(),
schemaName, (ShardingSphereTable)actualTableMetaData.get(),
logicDataSourceNames.isEmpty() ? null :
(String)logicDataSourceNames.iterator().next());
if (isSingleTable &&
TableRefreshUtils.isRuleRefreshRequired(ruleMetaData, schemaName, tableName)) {
metaDataManagerPersistService.alterSingleRuleConfiguration(database.getName(),
ruleMetaData.getConfigurations());
}
}
public Class<CreateTableStatement> getType() {
return CreateTableStatement.class;
}
}
```
// tmp_sys_user is TEMPORARY TABLE
Preconditions.checkState(actualTableMetaData.isPresent(), "Load actual
table metadata '%s' failed.", tableName);
```text
### Error updating database. Cause: java.sql.SQLException: Unknown
exception.
More details: java.lang.IllegalStateException: Load actual table metadata
'tmp_sys_user' failed.
### The error may exist in file
[E:\2025\apps-kts\app-mybatis-plus\out\production\resources\mapper\DemoMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: CREATE TEMPORARY TABLE tmp_sys_user AS SELECT * FROM sys_user WHERE
nickname like 'user%'
### Cause: java.sql.SQLException: Unknown exception.
More details: java.lang.IllegalStateException: Load actual table metadata
'tmp_sys_user' failed.
; uncategorized SQLException; SQL state [HY000]; error code [30000]; Unknown
exception.
More details: java.lang.IllegalStateException: Load actual table metadata
'tmp_sys_user' failed.] with root cause
```
--
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:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]