public class ConfigGridSQLHandler extends AbstractActionHandler<ConfigGridSQL, ConfigGridSQLResult> {
@Inject public ConfigGridSQLHandler() { super(ConfigGridSQL.class); }
public ConfigGridSQLResult execute(ConfigGridSQL arg0, ExecutionContext arg1) throws ActionException { String primaryKeyName = null; List<MetaDataFieldConfigSQL> list = null;
try { String sql = "SELECT k.COLUMN_NAME FROM information_schema.table_constraints t LEFT JOIN information_schema.key_column_usage k USING(constraint_name,table_schema,table_name) WHERE t.constraint_type='PRIMARY KEY' AND t.table_schema=DATABASE() AND t.table_name=:TABLE_NAME"; SQLQuery query = {INJECT SESSIONFACTORY HIBERNATE}.openSession().createSQLQuery(sql); query.setParameter("TABLE_NAME", SQLToolsImpl.getFirstTableFromSQL(arg0.getSql()).toUpperCase().trim()); System.out.println(SQLToolsImpl.getFirstTableFromSQL(arg0.getSql()).toUpperCase().trim()); List<Object[]> resultKey = query.list(); System.out.println(resultKey.size()); if (resultKey.size() != 0) { primaryKeyName = String.valueOf(resultKey.get(0)); } else { throw new PrimaryKeyNotFound(); } list = SQLToolsImpl.getColumnFromSQL(getSessionFactory(), arg0.getSql());
} catch (HibernateException | JSQLParserException e) { throw new OtherPrimaryKeyException(e.getMessage()); } return new ConfigGridSQLResult(primaryKeyName, list);
@Override public void undo(ConfigGridSQL action, ConfigGridSQLResult result, ExecutionContext context) throws ActionException { // TODO Auto-generated method stub
}
--
You received this message because you are subscribed to a topic in the Google Groups "GWTP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gwt-platform/-TVLttt40Qs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gwt-platform...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.