use of io.seata.common.exception.NotSupportYetException in project seata by seata.
the class PostgresqlUpdateRecognizer method getTableName.
@Override
public String getTableName() {
StringBuilder sb = new StringBuilder();
PGOutputVisitor visitor = new PGOutputVisitor(sb) {
@Override
public boolean visit(SQLExprTableSource x) {
printTableSourceExpr(x.getExpr());
return false;
}
@Override
public boolean visit(SQLJoinTableSource x) {
throw new NotSupportYetException("not support the syntax of update with join table");
}
};
SQLTableSource tableSource = ast.getTableSource();
if (tableSource instanceof SQLExprTableSource) {
visitor.visit((SQLExprTableSource) tableSource);
} else if (tableSource instanceof SQLJoinTableSource) {
visitor.visit((SQLJoinTableSource) tableSource);
} else {
throw new NotSupportYetException("not support the syntax of update with unknow");
}
return sb.toString();
}
use of io.seata.common.exception.NotSupportYetException in project seata by seata.
the class RegistryFactory method buildRegistryService.
private static RegistryService buildRegistryService() {
RegistryType registryType;
String registryTypeName = ConfigurationFactory.CURRENT_FILE_INSTANCE.getConfig(ConfigurationKeys.FILE_ROOT_REGISTRY + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR + ConfigurationKeys.FILE_ROOT_TYPE);
try {
registryType = RegistryType.getType(registryTypeName);
} catch (Exception exx) {
throw new NotSupportYetException("not support registry type: " + registryTypeName);
}
if (RegistryType.File == registryType) {
return FileRegistryServiceImpl.getInstance();
} else {
return EnhancedServiceLoader.load(RegistryProvider.class, Objects.requireNonNull(registryType).name()).provide();
}
}
use of io.seata.common.exception.NotSupportYetException in project seata by seata.
the class BaseInsertExecutor method getGeneratedKeys.
/**
* default get generated keys.
* @return
* @throws SQLException
*/
public List<Object> getGeneratedKeys() throws SQLException {
// PK is just auto generated
ResultSet genKeys = statementProxy.getGeneratedKeys();
List<Object> pkValues = new ArrayList<>();
while (genKeys.next()) {
Object v = genKeys.getObject(1);
pkValues.add(v);
}
if (pkValues.isEmpty()) {
throw new NotSupportYetException(String.format("not support sql [%s]", sqlRecognizer.getOriginalSQL()));
}
try {
genKeys.beforeFirst();
} catch (SQLException e) {
LOGGER.warn("Fail to reset ResultSet cursor. can not get primary key value");
}
return pkValues;
}
use of io.seata.common.exception.NotSupportYetException in project seata by seata.
the class BaseInsertExecutor method getPkValuesBySequence.
/**
* the modify for test
*
* @param expr the expr
* @return the pk values by sequence
* @throws SQLException the sql exception
*/
protected List<Object> getPkValuesBySequence(SqlSequenceExpr expr) throws SQLException {
List<Object> pkValues = null;
try {
pkValues = getGeneratedKeys();
} catch (NotSupportYetException | SQLException ignore) {
}
if (!CollectionUtils.isEmpty(pkValues)) {
return pkValues;
}
Sequenceable sequenceable = (Sequenceable) this;
final String sql = sequenceable.getSequenceSql(expr);
LOGGER.warn("Fail to get auto-generated keys, use '{}' instead. Be cautious, statement could be polluted. Recommend you set the statement to return generated keys.", sql);
ResultSet genKeys;
genKeys = statementProxy.getConnection().createStatement().executeQuery(sql);
pkValues = new ArrayList<>();
while (genKeys.next()) {
Object v = genKeys.getObject(1);
pkValues.add(v);
}
return pkValues;
}
use of io.seata.common.exception.NotSupportYetException in project seata by seata.
the class MultiDeleteExecutor method beforeImage.
@Override
protected TableRecords beforeImage() throws SQLException {
if (sqlRecognizers.size() == 1) {
DeleteExecutor executor = new DeleteExecutor(statementProxy, statementCallback, sqlRecognizers.get(0));
return executor.beforeImage();
}
final TableMeta tmeta = getTableMeta(sqlRecognizers.get(0).getTableName());
final ArrayList<List<Object>> paramAppenderList = new ArrayList<>();
StringBuilder whereCondition = new StringBuilder();
for (SQLRecognizer recognizer : sqlRecognizers) {
sqlRecognizer = recognizer;
SQLDeleteRecognizer visitor = (SQLDeleteRecognizer) recognizer;
ParametersHolder parametersHolder = statementProxy instanceof ParametersHolder ? (ParametersHolder) statementProxy : null;
if (StringUtils.isNotBlank(visitor.getLimit(parametersHolder, paramAppenderList))) {
throw new NotSupportYetException("Multi delete SQL with limit condition is not support yet !");
}
if (StringUtils.isNotBlank(visitor.getOrderBy())) {
throw new NotSupportYetException("Multi delete SQL with orderBy condition is not support yet !");
}
String whereConditionStr = buildWhereCondition(visitor, paramAppenderList);
if (StringUtils.isBlank(whereConditionStr)) {
whereCondition = new StringBuilder();
paramAppenderList.clear();
break;
}
if (whereCondition.length() > 0) {
whereCondition.append(" OR ");
}
whereCondition.append(whereConditionStr);
}
StringBuilder suffix = new StringBuilder(" FROM ").append(getFromTableInSQL());
if (whereCondition.length() > 0) {
suffix.append(" WHERE ").append(whereCondition);
}
suffix.append(" FOR UPDATE");
final StringJoiner selectSQLAppender = new StringJoiner(", ", "SELECT ", suffix.toString());
for (String column : tmeta.getAllColumns().keySet()) {
selectSQLAppender.add(getColumnNameInSQL(ColumnUtils.addEscape(column, getDbType())));
}
return buildTableRecords(tmeta, selectSQLAppender.toString(), paramAppenderList);
}
Aggregations