Search in sources :

Example 1 with ConfigurationMetadataDescriptor

use of org.jboss.tools.hibernate.runtime.v_5_6.internal.util.ConfigurationMetadataDescriptor in project jbosstools-hibernate by jbosstools.

the class ServiceImpl method createExporter.

@Override
public IExporter createExporter(String exporterClassName) {
    Exporter exporter = (Exporter) Util.getInstance(exporterClassName, facadeFactory.getClassLoader());
    exporter.setMetadataDescriptor(new ConfigurationMetadataDescriptor(newDefaultConfiguration()));
    return facadeFactory.createExporter(exporter);
}
Also used : ConfigurationMetadataDescriptor(org.jboss.tools.hibernate.runtime.v_5_3.internal.util.ConfigurationMetadataDescriptor) IHibernateMappingExporter(org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter) Exporter(org.hibernate.tool.hbm2x.Exporter) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter)

Example 2 with ConfigurationMetadataDescriptor

use of org.jboss.tools.hibernate.runtime.v_5_6.internal.util.ConfigurationMetadataDescriptor in project jbosstools-hibernate by jbosstools.

the class ExporterFacadeImpl method setConfiguration.

@Override
public void setConfiguration(IConfiguration configuration) {
    Exporter exporter = (Exporter) getTarget();
    setCustomProperties(configuration.getProperties());
    exporter.setMetadataDescriptor(new ConfigurationMetadataDescriptor(configuration));
}
Also used : ConfigurationMetadataDescriptor(org.jboss.tools.hibernate.runtime.v_5_6.internal.util.ConfigurationMetadataDescriptor) Exporter(org.hibernate.tool.hbm2x.Exporter)

Example 3 with ConfigurationMetadataDescriptor

use of org.jboss.tools.hibernate.runtime.v_5_6.internal.util.ConfigurationMetadataDescriptor in project jbosstools-hibernate by jbosstools.

the class ExporterFacadeTest method testSetConfiguration.

@Test
public void testSetConfiguration() throws Exception {
    exporterTarget = new HibernateConfigurationExporter();
    exporterFacade = new ExporterFacadeImpl(FACADE_FACTORY, exporterTarget);
    Properties properties = new Properties();
    Configuration configurationTarget = new Configuration();
    configurationTarget.setProperties(properties);
    ConfigurationFacadeImpl configurationFacade1 = new ConfigurationFacadeImpl(FACADE_FACTORY, configurationTarget);
    exporterFacade.setConfiguration(configurationFacade1);
    assertSame(properties, ((HibernateConfigurationExporter) exporterTarget).getCustomProperties());
    Field metadataDescriptorField = AbstractExporter.class.getDeclaredField("metadataDescriptor");
    metadataDescriptorField.setAccessible(true);
    ConfigurationMetadataDescriptor configurationMetadataDescriptor = (ConfigurationMetadataDescriptor) metadataDescriptorField.get(exporterTarget);
    assertNotNull(configurationMetadataDescriptor);
    Field configurationFacadeField = ConfigurationMetadataDescriptor.class.getDeclaredField("configuration");
    configurationFacadeField.setAccessible(true);
    ConfigurationFacadeImpl configurationFacade2 = (ConfigurationFacadeImpl) configurationFacadeField.get(configurationMetadataDescriptor);
    assertNotNull(configurationFacade2);
    assertSame(configurationFacade1, configurationFacade2);
}
Also used : Field(java.lang.reflect.Field) ConfigurationMetadataDescriptor(org.jboss.tools.hibernate.runtime.v_5_3.internal.util.ConfigurationMetadataDescriptor) HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) Configuration(org.hibernate.cfg.Configuration) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigurationMetadataDescriptor

use of org.jboss.tools.hibernate.runtime.v_5_6.internal.util.ConfigurationMetadataDescriptor in project jbosstools-hibernate by jbosstools.

the class ExporterFacadeTest method testSetConfiguration.

@Test
public void testSetConfiguration() throws Exception {
    exporterTarget = new CfgExporter();
    exporterFacade = new ExporterFacadeImpl(FACADE_FACTORY, exporterTarget);
    Properties properties = new Properties();
    Configuration configurationTarget = new Configuration();
    configurationTarget.setProperties(properties);
    ConfigurationFacadeImpl configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configurationTarget);
    exporterFacade.setConfiguration(configurationFacade);
    assertSame(properties, ((CfgExporter) exporterTarget).getCustomProperties());
    Object object = exporterTarget.getProperties().get(ExporterConstants.METADATA_DESCRIPTOR);
    assertNotNull(object);
    assertTrue(object instanceof ConfigurationMetadataDescriptor);
    ConfigurationMetadataDescriptor configurationMetadataDescriptor = (ConfigurationMetadataDescriptor) object;
    Field field = ConfigurationMetadataDescriptor.class.getDeclaredField("configurationFacade");
    field.setAccessible(true);
    object = field.get(configurationMetadataDescriptor);
    assertNotNull(object);
    assertTrue(object instanceof ConfigurationFacadeImpl);
    assertSame(object, configurationFacade);
}
Also used : Field(java.lang.reflect.Field) ConfigurationMetadataDescriptor(org.jboss.tools.hibernate.runtime.v_6_0.internal.util.ConfigurationMetadataDescriptor) Configuration(org.hibernate.cfg.Configuration) CfgExporter(org.hibernate.tool.internal.export.cfg.CfgExporter) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 5 with ConfigurationMetadataDescriptor

use of org.jboss.tools.hibernate.runtime.v_5_6.internal.util.ConfigurationMetadataDescriptor in project jbosstools-hibernate by jbosstools.

the class ConfigurationMetadataDescriptorTest method beforeEach.

@BeforeEach
public void beforeEach() {
    configurationTarget = new Configuration();
    configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configurationTarget);
    configurationMetadataDescriptor = new ConfigurationMetadataDescriptor(configurationFacade);
}
Also used : Configuration(org.hibernate.cfg.Configuration) ConfigurationFacadeImpl(org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Test (org.junit.jupiter.api.Test)10 Field (java.lang.reflect.Field)9 Configuration (org.hibernate.cfg.Configuration)7 Properties (java.util.Properties)5 Exporter (org.hibernate.tool.hbm2x.Exporter)5 HibernateConfigurationExporter (org.hibernate.tool.hbm2x.HibernateConfigurationExporter)4 ConfigurationMetadataDescriptor (org.jboss.tools.hibernate.runtime.v_5_3.internal.util.ConfigurationMetadataDescriptor)4 ConfigurationMetadataDescriptor (org.jboss.tools.hibernate.runtime.v_5_4.internal.util.ConfigurationMetadataDescriptor)3 ConfigurationMetadataDescriptor (org.jboss.tools.hibernate.runtime.v_5_5.internal.util.ConfigurationMetadataDescriptor)3 ConfigurationMetadataDescriptor (org.jboss.tools.hibernate.runtime.v_5_6.internal.util.ConfigurationMetadataDescriptor)3 ConfigurationFacadeImpl (org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl)2 ConfigurationMetadataDescriptor (org.jboss.tools.hibernate.runtime.v_6_0.internal.util.ConfigurationMetadataDescriptor)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Metadata (org.hibernate.boot.Metadata)1 MetadataSources (org.hibernate.boot.MetadataSources)1 PersistentClass (org.hibernate.mapping.PersistentClass)1 RootClass (org.hibernate.mapping.RootClass)1 CfgExporter (org.hibernate.tool.internal.export.cfg.CfgExporter)1 IExporter (org.jboss.tools.hibernate.runtime.spi.IExporter)1 IHibernateMappingExporter (org.jboss.tools.hibernate.runtime.spi.IHibernateMappingExporter)1