use of org.hibernate.console.execution.ExecutionContext.Command in project jbosstools-hibernate by jbosstools.
the class HibernateExtension method executeCriteriaQuery.
public QueryPage executeCriteriaQuery(final String criteriaCode, final QueryInputModel model) {
return (QueryPage) execute(new Command() {
public Object execute() {
ISession session = sessionFactory.openSession();
QueryPage qp = new JavaPage(HibernateExtension.this, criteriaCode, model);
qp.setSession(session);
return qp;
}
});
}
use of org.hibernate.console.execution.ExecutionContext.Command in project jbosstools-hibernate by jbosstools.
the class SchemaExportAction method doRun.
public void doRun() {
for (Iterator<?> i = getSelectedNonResources().iterator(); i.hasNext(); ) {
Object node = i.next();
if (!(node instanceof ConsoleConfiguration)) {
continue;
}
final ConsoleConfiguration config = (ConsoleConfiguration) node;
try {
config.execute(new Command() {
public Object execute() {
final IConfiguration cfg = config.getConfiguration();
if (cfg == null) {
return null;
}
String out = NLS.bind(HibernateConsoleMessages.SchemaExportAction_sure_run_schemaexport, config.getName());
boolean res = openWarningYesNoDlg(viewer.getControl().getShell(), HibernateConsoleMessages.SchemaExportAction_run_schemaexport, out);
if (!res) {
return null;
}
IService service = config.getHibernateExtension().getHibernateService();
ISchemaExport export = service.newSchemaExport(cfg);
export.create();
if (!export.getExceptions().isEmpty()) {
Iterator<Throwable> iterator = export.getExceptions().iterator();
int cnt = 1;
while (iterator.hasNext()) {
Throwable element = iterator.next();
String outStr = NLS.bind(HibernateConsoleMessages.SchemaExportAction_errornum_while_performing_schemaexport, cnt++);
HibernateConsolePlugin.getDefault().logErrorMessage(outStr, element);
}
HibernateConsolePlugin.getDefault().showError(viewer.getControl().getShell(), NLS.bind(HibernateConsoleMessages.SchemaExportAction_error_while_performing_schemaexport, cnt - 1), (Throwable) null);
}
return null;
}
});
// todo: should we do it here or should
viewer.refresh(node);
// the view just react to config being
// build ?
} catch (Exception he) {
HibernateConsolePlugin.getDefault().showError(viewer.getControl().getShell(), HibernateConsoleMessages.SchemaExportAction_exception_running_schemaexport, he);
}
}
}
Aggregations