use of org.jboss.tools.hibernate.runtime.spi.IPrimaryKey in project jbosstools-hibernate by jbosstools.
the class TableFacadeTest method testGetPrimaryKey.
@Test
public void testGetPrimaryKey() {
Table table = new Table();
PrimaryKey primaryKey = new PrimaryKey(table);
ITable tableFacade = FACADE_FACTORY.createTable(table);
Assert.assertNull(tableFacade.getPrimaryKey());
table.setPrimaryKey(primaryKey);
IPrimaryKey primaryKeyFacade = tableFacade.getPrimaryKey();
Assert.assertSame(primaryKey, ((IFacade) primaryKeyFacade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.IPrimaryKey in project jbosstools-hibernate by jbosstools.
the class TypeMappingView method doAdd.
private void doAdd() {
ISelection selection = viewer.getSelection();
if (!selection.isEmpty()) {
StructuredSelection ss = (StructuredSelection) selection;
Iterator<?> iterator = ss.iterator();
while (iterator.hasNext()) {
Object sel = iterator.next();
if (sel instanceof IColumn) {
IColumn col = (IColumn) sel;
Integer sqlTypeCode = col.getSqlTypeCode();
createTypeMapping(col, sqlTypeCode);
} else if (sel instanceof IPrimaryKey) {
IPrimaryKey pk = (IPrimaryKey) sel;
Iterator<IColumn> iter = pk.columnIterator();
while (iter.hasNext()) {
IColumn column = (IColumn) iter.next();
createTypeMapping(column, column.getSqlTypeCode());
}
} else {
createDefaultSqlTypeMapping();
}
}
} else {
createDefaultSqlTypeMapping();
}
}
use of org.jboss.tools.hibernate.runtime.spi.IPrimaryKey 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.jboss.tools.hibernate.runtime.spi.IPrimaryKey in project jbosstools-hibernate by jbosstools.
the class TableFacadeTest method testGetPrimaryKey.
@Test
public void testGetPrimaryKey() {
PrimaryKey primaryKey = new PrimaryKey();
Table table = new Table();
ITable tableFacade = FACADE_FACTORY.createTable(table);
Assert.assertNull(tableFacade.getPrimaryKey());
table.setPrimaryKey(primaryKey);
IPrimaryKey primaryKeyFacade = tableFacade.getPrimaryKey();
Assert.assertSame(primaryKey, ((IFacade) primaryKeyFacade).getTarget());
}
use of org.jboss.tools.hibernate.runtime.spi.IPrimaryKey in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreatePrimaryKey.
@Test
public void testCreatePrimaryKey() {
PrimaryKey primaryKey = new PrimaryKey();
IPrimaryKey facade = facadeFactory.createPrimaryKey(primaryKey);
Assert.assertSame(primaryKey, ((IFacade) facade).getTarget());
}
Aggregations