Search in sources :

Example 1 with QueryPage

use of org.hibernate.console.QueryPage in project jbosstools-hibernate by jbosstools.

the class HibernateExtension method executeHQLQuery.

public QueryPage executeHQLQuery(final String hql, final QueryInputModel queryParameters) {
    return (QueryPage) execute(new Command() {

        public Object execute() {
            ISession session = sessionFactory.openSession();
            QueryPage qp = new HQLQueryPage(HibernateExtension.this, hql, queryParameters);
            qp.setSession(session);
            return qp;
        }
    });
}
Also used : ISession(org.jboss.tools.hibernate.runtime.spi.ISession) Command(org.hibernate.console.execution.ExecutionContext.Command) QueryPage(org.hibernate.console.QueryPage)

Example 2 with QueryPage

use of org.hibernate.console.QueryPage in project jbosstools-hibernate by jbosstools.

the class ConsoleConfigurationTest method testBuildConfiguration.

@Test
public void testBuildConfiguration() {
    MockCCListener listener = new MockCCListener();
    Assert.assertTrue(consoleCfg.getConsoleConfigurationListeners().length == 1);
    consoleCfg.addConsoleConfigurationListener(listener);
    consoleCfg.build();
    Assert.assertEquals(0, listener.factoryBuilt);
    consoleCfg.buildSessionFactory();
    Assert.assertEquals(1, listener.factoryBuilt);
    try {
        consoleCfg.buildSessionFactory();
        Assert.fail(TestConsoleMessages.ConsoleConfigurationTest_factory_already_exists);
    } catch (HibernateConsoleRuntimeException hcre) {
    }
    // $NON-NLS-1$
    QueryPage qp = consoleCfg.executeHQLQuery("from java.lang.Object");
    Assert.assertNotNull(qp);
    Assert.assertEquals(1, listener.queryCreated);
    consoleCfg.closeSessionFactory();
    Assert.assertEquals(1, listener.factoryClosing);
}
Also used : QueryPage(org.hibernate.console.QueryPage) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) Test(org.junit.Test)

Example 3 with QueryPage

use of org.hibernate.console.QueryPage in project jbosstools-hibernate by jbosstools.

the class ConsoleConfigurationTest method testHQLComments.

@Test
public void testHQLComments() {
    consoleCfg.build();
    consoleCfg.buildSessionFactory();
    try {
        consoleCfg.buildSessionFactory();
        Assert.fail(TestConsoleMessages.ConsoleConfigurationTest_factory_already_exists);
    } catch (HibernateConsoleRuntimeException hcre) {
    }
    // $NON-NLS-1$
    QueryPage qp = consoleCfg.executeHQLQuery("from java.lang.Object --this is my comment");
    Assert.assertNotNull(qp);
}
Also used : QueryPage(org.hibernate.console.QueryPage) HibernateConsoleRuntimeException(org.hibernate.console.HibernateConsoleRuntimeException) Test(org.junit.Test)

Example 4 with QueryPage

use of org.hibernate.console.QueryPage in project jbosstools-hibernate by jbosstools.

the class QueryPageTabView method createPartControl.

public void createPartControl(Composite parent) {
    tabs = new CTabFolder(parent, SWT.CLOSE | SWT.BOTTOM);
    tabs.setSimple(false);
    tabs.setUnselectedCloseVisible(false);
    tabs.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            fireSelectionChangedEvent();
        }
    });
    tabs.addCTabFolder2Listener(new CTabFolder2Adapter() {

        public void close(CTabFolderEvent event) {
            QueryPage qp = (QueryPage) event.item.getData();
            KnownConfigurations.getInstance().getQueryPageModel().remove(qp);
        }
    });
    rebuild();
    initActions();
    provideSelection();
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) CTabFolder2Adapter(org.eclipse.swt.custom.CTabFolder2Adapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CTabFolderEvent(org.eclipse.swt.custom.CTabFolderEvent) QueryPage(org.hibernate.console.QueryPage)

Example 5 with QueryPage

use of org.hibernate.console.QueryPage 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;
        }
    });
}
Also used : ISession(org.jboss.tools.hibernate.runtime.spi.ISession) Command(org.hibernate.console.execution.ExecutionContext.Command) QueryPage(org.hibernate.console.QueryPage)

Aggregations

QueryPage (org.hibernate.console.QueryPage)8 HibernateConsoleRuntimeException (org.hibernate.console.HibernateConsoleRuntimeException)3 Test (org.junit.Test)3 Command (org.hibernate.console.execution.ExecutionContext.Command)2 ISession (org.jboss.tools.hibernate.runtime.spi.ISession)2 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 CTabFolder2Adapter (org.eclipse.swt.custom.CTabFolder2Adapter)1 CTabFolderEvent (org.eclipse.swt.custom.CTabFolderEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 IViewPart (org.eclipse.ui.IViewPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IPropertySource (org.eclipse.ui.views.properties.IPropertySource)1 ConsoleQueryParameter (org.hibernate.console.ConsoleQueryParameter)1 QueryInputModel (org.hibernate.console.QueryInputModel)1 ConsoleExtension (org.hibernate.eclipse.console.common.ConsoleExtension)1 IColumn (org.jboss.tools.hibernate.runtime.spi.IColumn)1 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)1 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)1 IPrimaryKey (org.jboss.tools.hibernate.runtime.spi.IPrimaryKey)1