Search in sources :

Example 91 with IConfiguration

use of org.jboss.tools.hibernate.runtime.spi.IConfiguration in project jbosstools-hibernate by jbosstools.

the class SchemaExportFacadeImpl method setConfiguration.

public void setConfiguration(IConfiguration configuration) {
    Configuration configurationTarget = (Configuration) ((IFacade) configuration).getTarget();
    this.metadata = MetadataHelper.getMetadata(configurationTarget);
}
Also used : IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Configuration(org.hibernate.cfg.Configuration)

Example 92 with IConfiguration

use of org.jboss.tools.hibernate.runtime.spi.IConfiguration in project jbosstools-hibernate by jbosstools.

the class ColumnFacadeImpl method getSqlType.

@Override
public String getSqlType(IConfiguration configuration) {
    Column targetColumn = (Column) getTarget();
    Configuration configurationTarget = (Configuration) ((IFacade) configuration).getTarget();
    Properties properties = configurationTarget.getProperties();
    StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder();
    ssrb.applySettings(properties);
    StandardServiceRegistry ssr = ssrb.build();
    DialectFactory df = ssr.getService(DialectFactory.class);
    Dialect dialectTarget = df.buildDialect(properties, null);
    return targetColumn.getSqlType(dialectTarget, MetadataHelper.getMetadata(configurationTarget));
}
Also used : IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Configuration(org.hibernate.cfg.Configuration) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Column(org.hibernate.mapping.Column) Dialect(org.hibernate.dialect.Dialect) DialectFactory(org.hibernate.engine.jdbc.dialect.spi.DialectFactory) Properties(java.util.Properties) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry)

Example 93 with IConfiguration

use of org.jboss.tools.hibernate.runtime.spi.IConfiguration in project jbosstools-hibernate by jbosstools.

the class OrmDiagram method refreshRootsFromNames.

public boolean refreshRootsFromNames() {
    final IConfiguration config = getConfig();
    if (config == null) {
        return false;
    }
    for (int i = 0; i < roots.size(); i++) {
        IPersistentClass newOrmElement = config.getClassMapping(entityNames.get(i));
        if (roots.get(i) == null) {
            if (newOrmElement == null) {
                continue;
            }
        } else if (roots.get(i).equals(newOrmElement)) {
            continue;
        }
        roots.set(i, newOrmElement);
    }
    return true;
}
Also used : IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) Point(org.eclipse.draw2d.geometry.Point) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 94 with IConfiguration

use of org.jboss.tools.hibernate.runtime.spi.IConfiguration in project jbosstools-hibernate by jbosstools.

the class HbmExporterTest method testProperty.

public void testProperty() {
    // $NON-NLS-1$
    IConfiguration config = getConfigurationFor("pack.A");
    // $NON-NLS-1$ //$NON-NLS-2$
    checkClassesMaped(config, "pack.A", "pack.B");
    // $NON-NLS-1$
    IPersistentClass a = config.getClassMapping("pack.A");
    // $NON-NLS-1$
    IProperty prop = a.getProperty("prop");
    assertNotNull(prop.getValue());
    IValue value = prop.getValue();
    // $NON-NLS-1$
    assertTrue("Expected to get ManyToOne-type mapping", value.isManyToOne());
    // $NON-NLS-1$
    assertEquals("pack.B", value.getTypeName());
}
Also used : IValue(org.jboss.tools.hibernate.runtime.spi.IValue) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 95 with IConfiguration

use of org.jboss.tools.hibernate.runtime.spi.IConfiguration in project jbosstools-hibernate by jbosstools.

the class HbmExporterTest method testSet.

public void testSet() {
    // $NON-NLS-1$
    IConfiguration config = getConfigurationFor("pack.A");
    // $NON-NLS-1$ //$NON-NLS-2$
    checkClassesMaped(config, "pack.A", "pack.B");
    // $NON-NLS-1$
    IPersistentClass a = config.getClassMapping("pack.A");
    // $NON-NLS-1$
    IPersistentClass b = config.getClassMapping("pack.B");
    // $NON-NLS-1$
    IProperty setProp = a.getProperty("set");
    assertNotNull(setProp.getValue());
    IValue value = setProp.getValue();
    assertTrue("Expected to get Set-type mapping", value.isSet());
    assertTrue(value.getCollectionElement().isOneToMany());
    assertTrue(value.getCollectionTable().equals(b.getTable()));
    assertNotNull(value.getKey());
}
Also used : IValue(org.jboss.tools.hibernate.runtime.spi.IValue) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Aggregations

IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)137 Test (org.junit.Test)72 Configuration (org.hibernate.cfg.Configuration)65 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)29 JDBCMetaDataConfiguration (org.hibernate.cfg.JDBCMetaDataConfiguration)25 File (java.io.File)19 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)17 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)16 Properties (java.util.Properties)13 CoreException (org.eclipse.core.runtime.CoreException)10 IReverseEngineeringStrategy (org.jboss.tools.hibernate.runtime.spi.IReverseEngineeringStrategy)10 IJDBCReader (org.jboss.tools.hibernate.runtime.spi.IJDBCReader)9 FileWriter (java.io.FileWriter)8 IOException (java.io.IOException)8 JDBCReader (org.hibernate.cfg.reveng.JDBCReader)8 SimpleValue (org.hibernate.mapping.SimpleValue)8 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)8 JavaModelException (org.eclipse.jdt.core.JavaModelException)7 PartInitException (org.eclipse.ui.PartInitException)7 Ejb3Configuration (org.hibernate.ejb.Ejb3Configuration)7