use of org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl in project jbosstools-hibernate by jbosstools.
the class ConfigurationMetadataDescriptor method patch.
private Metadata patch(Metadata metadata) {
try {
if (metadata instanceof MetadataImpl) {
MetadataImpl metadataImpl = (MetadataImpl) metadata;
Field entityBindingMapField = metadataImpl.getClass().getDeclaredField("entityBindingMap");
if (entityBindingMapField != null) {
entityBindingMapField.setAccessible(true);
Object object = entityBindingMapField.get(metadataImpl);
if (object instanceof HashMap<?, ?>) {
@SuppressWarnings("unchecked") HashMap<String, PersistentClass> map = (HashMap<String, PersistentClass>) object;
for (IPersistentClass ipc : ((ConfigurationFacadeImpl) this.configurationFacade).getAddedClasses()) {
PersistentClass pc = (PersistentClass) ((IFacade) ipc).getTarget();
map.put(pc.getEntityName(), pc);
}
}
}
}
return metadata;
} catch (Throwable t) {
throw new RuntimeException("Problem while creating metadata", t);
}
}
use of org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl in project jbosstools-hibernate by jbosstools.
the class SchemaExportFacadeTest method testSetConfiguration.
@Test
public void testSetConfiguration() throws Exception {
Field metadataField = SchemaExportFacadeImpl.class.getDeclaredField("metadata");
metadataField.setAccessible(true);
Configuration configurationTarget = new Configuration();
configurationTarget.setProperty(AvailableSettings.DIALECT, MockDialect.class.getName());
configurationTarget.setProperty(AvailableSettings.CONNECTION_PROVIDER, MockConnectionProvider.class.getName());
ConfigurationFacadeImpl configuration = new ConfigurationFacadeImpl(FACADE_FACTORY, configurationTarget);
Metadata metadata = configuration.getMetadata();
assertNull(metadataField.get(schemaExportFacade));
schemaExportFacade.setConfiguration(configuration);
assertSame(metadata, metadataField.get(schemaExportFacade));
}
use of org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl 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);
}
use of org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl 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);
}
use of org.jboss.tools.hibernate.runtime.v_5_6.internal.ConfigurationFacadeImpl in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testGetClassMappings.
@Test
public void testGetClassMappings() throws Exception {
Field addedClassesField = ConfigurationFacadeImpl.class.getDeclaredField("addedClasses");
addedClassesField.setAccessible(true);
configuration.setProperty("hibernate.dialect", TestDialect.class.getName());
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
assertFalse(configurationFacade.getClassMappings().hasNext());
PersistentClass persistentClass = new RootClass(null);
persistentClass.setEntityName("Foo");
IPersistentClass persistentClassFacade = FACADE_FACTORY.createPersistentClass(persistentClass);
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
@SuppressWarnings("unchecked") List<IPersistentClass> addedClasses = (List<IPersistentClass>) addedClassesField.get(configurationFacade);
addedClasses.add(persistentClassFacade);
Iterator<IPersistentClass> iterator = configurationFacade.getClassMappings();
assertTrue(iterator.hasNext());
assertSame(iterator.next(), persistentClassFacade);
}
Aggregations