use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testAddClass.
@Test
public void testAddClass() throws Exception {
PersistentClass persistentClass = new RootClass(null);
persistentClass.setEntityName("Foo");
IPersistentClass persistentClassFacade = FACADE_FACTORY.createPersistentClass(persistentClass);
Field addedClassesField = ConfigurationFacadeImpl.class.getDeclaredField("addedClasses");
addedClassesField.setAccessible(true);
Collection<?> addedClasses = (Collection<?>) addedClassesField.get(configurationFacade);
assertFalse(addedClasses.contains(persistentClassFacade));
configurationFacade.addClass(persistentClassFacade);
assertTrue(addedClasses.contains(persistentClassFacade));
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeTest method testGetClassMapping.
@Test
public void testGetClassMapping() throws Exception {
PersistentClass persistentClass = new RootClass(null);
persistentClass.setEntityName("Foo");
IPersistentClass persistentClassFacade = FACADE_FACTORY.createPersistentClass(persistentClass);
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
assertNull(configurationFacade.getClassMapping("Foo"));
configurationFacade = new ConfigurationFacadeImpl(FACADE_FACTORY, configuration);
Field addedClassesField = ConfigurationFacadeImpl.class.getDeclaredField("addedClasses");
addedClassesField.setAccessible(true);
@SuppressWarnings("unchecked") List<IPersistentClass> addedClasses = (List<IPersistentClass>) addedClassesField.get(configurationFacade);
addedClasses.add(persistentClassFacade);
assertSame(configurationFacade.getClassMapping("Foo"), persistentClassFacade);
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class EntityMetamodelFacadeTest method createPersistentClass.
private PersistentClass createPersistentClass(MetadataBuildingContext metadataBuildingContext) {
RootClass rc = new RootClass(metadataBuildingContext);
Table t = new Table("foobar");
rc.setTable(t);
Column c = new Column("foo");
t.addColumn(c);
ArrayList<Column> keyList = new ArrayList<>();
keyList.add(c);
t.createUniqueKey(keyList);
SimpleValue sv = new SimpleValue(metadataBuildingContext, t);
sv.setNullValue("null");
sv.setTypeName(Integer.class.getName());
sv.addColumn(c);
rc.setEntityName("foobar");
rc.setIdentifier(sv);
rc.setClassName(FooBar.class.getName());
rc.setOptimisticLockStyle(OptimisticLockStyle.NONE);
return rc;
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class TypeFacadeTest method testIsComponentType.
@Test
public void testIsComponentType() {
IType typeFacade = null;
ClassType classType = new ClassType();
typeFacade = FACADE_FACTORY.createType(classType);
assertFalse(typeFacade.isComponentType());
StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder();
ssrb.applySetting(AvailableSettings.DIALECT, TestDialect.class.getName());
StandardServiceRegistry ssr = ssrb.build();
MetadataBuildingOptions mdbo = new MetadataBuilderImpl.MetadataBuildingOptionsImpl(ssr);
MetadataImplementor mdi = (MetadataImplementor) new MetadataBuilderImpl(new MetadataSources(ssr)).build();
ComponentType componentType = new ComponentType(null, new ComponentMetamodel(new Component(mdi, new RootClass(null)), mdbo));
typeFacade = FACADE_FACTORY.createType(componentType);
assertTrue(typeFacade.isComponentType());
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class PersistentClassFacadeTest method testIsJoinedSubclass.
@Test
public void testIsJoinedSubclass() {
persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, new RootClass(null));
assertFalse(persistentClassFacade.isJoinedSubclass());
Table rootTable = new Table();
Table subTable = new Table();
RootClass rootClass = new RootClass(null);
rootClass.setTable(rootTable);
JoinedSubclass subclass = new JoinedSubclass(rootClass, null);
subclass.setTable(subTable);
persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, subclass) {
};
assertTrue(persistentClassFacade.isJoinedSubclass());
subclass.setTable(rootTable);
assertFalse(persistentClassFacade.isJoinedSubclass());
}
Aggregations