use of org.jboss.tools.hibernate.runtime.v_5_3.internal.ConfigurationFacadeImpl in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testSetPreferBasicCompositeIds.
@Test
public void testSetPreferBasicCompositeIds() {
JdbcMetadataConfiguration configuration = new JdbcMetadataConfiguration();
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
// the default is true
assertTrue(configuration.preferBasicCompositeIds());
configurationFacade.setPreferBasicCompositeIds(false);
assertFalse(configuration.preferBasicCompositeIds());
}
use of org.jboss.tools.hibernate.runtime.v_5_3.internal.ConfigurationFacadeImpl in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testSetReverseEngineeringStrategy.
@Test
public void testSetReverseEngineeringStrategy() {
JdbcMetadataConfiguration configuration = new JdbcMetadataConfiguration();
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
ReverseEngineeringStrategy reverseEngineeringStrategy = new DefaultReverseEngineeringStrategy();
IReverseEngineeringStrategy strategyFacade = FACADE_FACTORY.createReverseEngineeringStrategy(reverseEngineeringStrategy);
assertNotSame(reverseEngineeringStrategy, configuration.getReverseEngineeringStrategy());
configurationFacade.setReverseEngineeringStrategy(strategyFacade);
assertSame(reverseEngineeringStrategy, configuration.getReverseEngineeringStrategy());
}
use of org.jboss.tools.hibernate.runtime.v_5_3.internal.ConfigurationFacadeImpl in project jbosstools-hibernate by jbosstools.
the class ConfigurationMetadataDescriptorTest method testCreateMetadata.
@Test
public void testCreateMetadata() {
MetadataSources metadataSources = new MetadataSources();
metadataSources.addInputStream(new ByteArrayInputStream(TEST_HBM_XML_STRING.getBytes()));
Configuration configuration = new Configuration(metadataSources);
configuration.setProperty(AvailableSettings.DIALECT, MockDialect.class.getName());
configuration.setProperty(AvailableSettings.CONNECTION_PROVIDER, MockConnectionProvider.class.getName());
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
PersistentClass persistentClass = new RootClass(DummyMetadataBuildingContext.INSTANCE);
persistentClass.setEntityName("Bar");
IPersistentClass persistentClassFacade = FACADE_FACTORY.createPersistentClass(persistentClass);
configurationFacade.addClass(persistentClassFacade);
configurationMetadataDescriptor = new ConfigurationMetadataDescriptor(configurationFacade);
Metadata metadata = configurationMetadataDescriptor.createMetadata();
assertNotNull(metadata.getEntityBinding(Foo.class.getName()));
assertNotNull(metadata.getEntityBinding("Bar"));
}
use of org.jboss.tools.hibernate.runtime.v_5_3.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.configuration).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_3.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);
}
}
Aggregations