use of org.hibernate.console.QueryPage in project jbosstools-hibernate by jbosstools.
the class ConsoleConfigurationTest method testHQLListParameters.
@Test
public void testHQLListParameters() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
// fix for https://issues.jboss.org/browse/JBIDE-9392
// the view calls jdbc connection
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = activePage.findView(QueryPageTabView.ID);
if (view != null) {
activePage.hideView(view);
view.dispose();
}
consoleCfg.build();
IConfiguration c = consoleCfg.getConfiguration();
IPersistentClass rc = service.newRootClass();
rc.setEntityName("java.awt.Button");
rc.setClassName("java.awt.Button");
IColumn column = service.newColumn("label");
ITable table = service.newTable("faketable");
IPrimaryKey pk = table.getPrimaryKey();
pk.addColumn(column);
rc.setTable(table);
table.addColumn(column);
IProperty fakeProp = service.newProperty();
fakeProp.setName("label");
IValue sv = service.newSimpleValue();
sv.addColumn(column);
sv.setTypeName("string");
sv.setTable(table);
fakeProp.setValue(sv);
rc.setIdentifierProperty(fakeProp);
rc.setIdentifier(fakeProp.getValue());
c.addClass(rc);
consoleCfg.buildSessionFactory();
ConsoleQueryParameter paramA = new ConsoleQueryParameter(service, "a", typeFactory.getIntegerType(), new Integer[] { new Integer(1), new Integer(2) });
ConsoleQueryParameter paramB = new ConsoleQueryParameter(service, "b", typeFactory.getIntegerType(), new Integer(3));
ConsoleQueryParameter paramOrdered = new ConsoleQueryParameter(service, "0", typeFactory.getIntegerType(), new Integer(4));
QueryInputModel model = new QueryInputModel(service);
model.addParameter(paramA);
model.addParameter(paramB);
model.addParameter(paramOrdered);
// $NON-NLS-1$
QueryPage qp = consoleCfg.executeHQLQuery("select count(*) from java.awt.Button where 1 in ( ?, :a, :b )", model);
Assert.assertNotNull(qp);
try {
// execute the query
qp.getList();
} catch (Exception e) {
// ignore - there is fake mapping
}
}
use of org.hibernate.console.QueryPage in project jbosstools-hibernate by jbosstools.
the class QueryPageTabView method rebuild.
protected void rebuild() {
QueryPage selection = getSelectedQueryPage();
for (QueryPage results : getAddedResultSets()) {
this.pageViewers.add(new QueryPageViewer(this, results));
}
for (QueryPage results : getRemovedResultSets()) {
QueryPageViewer viewer = findViewerFor(results);
this.pageViewers.remove(viewer);
viewer.dispose();
}
// Handle firing selection changes here to cover for when the model fire changes
// but the Tab widget doesn't (e.g. the first page).
QueryPage newSelection = getSelectedQueryPage();
if (selection != null && newSelection == null) {
fireSelectionChangedEvent();
} else if (selection == null && newSelection != null) {
fireSelectionChangedEvent();
} else if (selection != null && !selection.equals(newSelection)) {
fireSelectionChangedEvent();
}
}
use of org.hibernate.console.QueryPage in project jbosstools-hibernate by jbosstools.
the class HibernatePropertySourceProvider method getPropertySource.
public IPropertySource getPropertySource(Object object) {
if (object == null) {
return null;
} else if (object instanceof QueryPage) {
return new QueryPagePropertySource((QueryPage) object);
} else if (object instanceof IPropertySource) {
return (IPropertySource) object;
} else {
QueryPage selectedQueryPage = view.getSelectedQueryPage();
ConsoleExtension consoleExtension = selectedQueryPage.getHibernateExtension().getConsoleExtension();
return consoleExtension.getPropertySource(object, selectedQueryPage);
/*return (IPropertySource) selectedQueryPage.getAdapter(IPropertySource.class);
// maybe we should be hooked up with the queryview to get this ?
Session currentSession = .getSession();
String consoleConfigName = view.getSelectedQueryPage().getConsoleConfiguration().getName();
if((currentSession.isOpen() && currentSession.contains(object)) || hasMetaData( object, currentSession) ) {
return new EntityPropertySource(object, currentSession, consoleConfigName);
} else {*/
// return null;
// }
}
}
Aggregations