forced fix
This commit is contained in:
parent
2ff21af101
commit
71c6422dcb
1 changed files with 11 additions and 10 deletions
|
|
@ -17,11 +17,9 @@ import org.jooq.DSLContext;
|
||||||
import org.jooq.Record;
|
import org.jooq.Record;
|
||||||
import org.jooq.Result;
|
import org.jooq.Result;
|
||||||
import org.jooq.exception.DataAccessException;
|
import org.jooq.exception.DataAccessException;
|
||||||
import org.jooq.impl.DSL;
|
|
||||||
import org.jooq.impl.DefaultDataType;
|
import org.jooq.impl.DefaultDataType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import service.button.sql.ExecuteSqlButtonService;
|
import service.button.sql.ExecuteSqlButtonService;
|
||||||
|
|
@ -32,7 +30,7 @@ import ru.cg.webbpm.modules.database.api.provider.DslProvider;
|
||||||
import ru.cg.webbpm.modules.standard_annotations.editor.TextAreaEditor;
|
import ru.cg.webbpm.modules.standard_annotations.editor.TextAreaEditor;
|
||||||
import ru.cg.webbpm.modules.standard_annotations.validation.NotNull;
|
import ru.cg.webbpm.modules.standard_annotations.validation.NotNull;
|
||||||
|
|
||||||
public class ReadOnlySqlButtonServiceImpl implements ExecuteSqlButtonService, InitializingBean {
|
public class ReadOnlySqlButtonServiceImpl implements ExecuteSqlButtonService {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ReadOnlySqlButtonServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(ReadOnlySqlButtonServiceImpl.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private DslProvider dslProvider;
|
private DslProvider dslProvider;
|
||||||
|
|
@ -44,10 +42,12 @@ public class ReadOnlySqlButtonServiceImpl implements ExecuteSqlButtonService, In
|
||||||
public String sql;
|
public String sql;
|
||||||
public String jndiName;
|
public String jndiName;
|
||||||
|
|
||||||
@Override
|
public void initDsl() {
|
||||||
public void afterPropertiesSet() {
|
|
||||||
dsl = this.dslProvider.getDslContext(jndiName);
|
|
||||||
|
|
||||||
|
if (dsl != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dsl = this.dslProvider.getDslContext(jndiName);
|
||||||
if (dsl == null) {
|
if (dsl == null) {
|
||||||
throw new RuntimeException("Couldn't get dslContext with datasourceJndiName = " + jndiName);
|
throw new RuntimeException("Couldn't get dslContext with datasourceJndiName = " + jndiName);
|
||||||
}
|
}
|
||||||
|
|
@ -55,6 +55,7 @@ public class ReadOnlySqlButtonServiceImpl implements ExecuteSqlButtonService, In
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<?> executeSql(Object[] params) {
|
public List<?> executeSql(Object[] params) {
|
||||||
|
initDsl();
|
||||||
SQLParameters parameters = new SQLParameters();
|
SQLParameters parameters = new SQLParameters();
|
||||||
parameters.setSql(sql);
|
parameters.setSql(sql);
|
||||||
parameters.setSqlParameters(params);
|
parameters.setSqlParameters(params);
|
||||||
|
|
@ -66,8 +67,7 @@ public class ReadOnlySqlButtonServiceImpl implements ExecuteSqlButtonService, In
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
private List<?> executeSelect(SQLParameters parameters) {
|
||||||
public List<?> executeSelect(SQLParameters parameters) {
|
|
||||||
Result<Record> result = executeSelectRaw(parameters);
|
Result<Record> result = executeSelectRaw(parameters);
|
||||||
|
|
||||||
if (result.size() > 1) {
|
if (result.size() > 1) {
|
||||||
|
|
@ -153,8 +153,9 @@ public class ReadOnlySqlButtonServiceImpl implements ExecuteSqlButtonService, In
|
||||||
if (SQLHandlerUtils.isArrayExceptBytesArray(parameter)) {
|
if (SQLHandlerUtils.isArrayExceptBytesArray(parameter)) {
|
||||||
Object[] castParameter = (Object[]) parameter;
|
Object[] castParameter = (Object[]) parameter;
|
||||||
org.jooq.SQLDialect dialect = dsl.configuration().dialect();
|
org.jooq.SQLDialect dialect = dsl.configuration().dialect();
|
||||||
String typeName = DefaultDataType.getDataType(dialect,castParameter.getClass().getComponentType())
|
String typeName = DefaultDataType.getDataType(dialect,
|
||||||
.getTypeName();
|
castParameter.getClass().getComponentType()
|
||||||
|
).getTypeName();
|
||||||
Array arrayOf = connection.createArrayOf(typeName, castParameter);
|
Array arrayOf = connection.createArrayOf(typeName, castParameter);
|
||||||
statement.setArray(i + 1, arrayOf);
|
statement.setArray(i + 1, arrayOf);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue