use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class ValueFacadeTest method testGetAssociatedClass.
@Test
public void testGetAssociatedClass() {
RootClass rootClass = new RootClass(null);
OneToMany oneToManyTarget = new OneToMany(DummyMetadataBuildingContext.INSTANCE, null);
valueFacade = FACADE_FACTORY.createValue(oneToManyTarget);
assertNull(valueFacade.getAssociatedClass());
oneToManyTarget.setAssociatedClass(rootClass);
assertSame(rootClass, ((IFacade) valueFacade.getAssociatedClass()).getTarget());
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class SpecialRootClassFacadeTest method testConstruction.
@Test
public void testConstruction() throws Exception {
PersistentClass persistentClassTarget = new RootClass(DummyMetadataBuildingContext.INSTANCE);
Property propertyTarget = new Property();
Component componentTarget = new Component(DummyMetadataBuildingContext.INSTANCE, persistentClassTarget);
componentTarget.setOwner(persistentClassTarget);
componentTarget.setParentProperty("fooBar");
propertyTarget.setValue(componentTarget);
propertyTarget.setPersistentClass(persistentClassTarget);
IProperty propertyFacade = FACADE_FACTORY.createProperty(propertyTarget);
specialRootClassFacade = new SpecialRootClassFacadeImpl(FACADE_FACTORY, propertyFacade);
Object specialRootClassTarget = ((IFacade) specialRootClassFacade).getTarget();
assertNotSame(propertyFacade, specialRootClassTarget);
assertTrue(specialRootClassTarget instanceof RootClass);
assertNotSame(specialRootClassTarget, persistentClassTarget);
Field propertyField = AbstractSpecialRootClassFacade.class.getDeclaredField("property");
propertyField.setAccessible(true);
assertSame(propertyField.get(specialRootClassFacade), propertyFacade);
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateHQLQueryPlan.
@Test
public void testCreateHQLQueryPlan() {
Configuration configuration = new Configuration();
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
Mappings mappings = configuration.createMappings();
Table t = new Table("FOO");
Column c = new Column("foo");
t.addColumn(c);
PrimaryKey key = new PrimaryKey();
key.addColumn(c);
t.setPrimaryKey(key);
Mappings m = configuration.createMappings();
SimpleValue sv = new SimpleValue(m);
sv.setNullValue("null");
sv.setTypeName(Integer.class.getName());
sv.setTable(t);
sv.addColumn(c);
RootClass rc = new RootClass();
rc.setEntityName("foo");
rc.setJpaEntityName("foo");
rc.setIdentifier(sv);
rc.setTable(t);
mappings.addClass(rc);
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
builder.applySettings(configuration.getProperties());
ServiceRegistry serviceRegistry = builder.build();
SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
Map<String, Filter> filters = Collections.emptyMap();
HQLQueryPlan hqlQueryPlan = new HQLQueryPlan("from foo", false, filters, sfi);
IHQLQueryPlan facade = facadeFactory.createHQLQueryPlan(hqlQueryPlan);
assertSame(hqlQueryPlan, ((IFacade) facade).getTarget());
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreatePersistentClass.
@Test
public void testCreatePersistentClass() {
PersistentClass persistentClass = new RootClass();
IPersistentClass facade = facadeFactory.createPersistentClass(persistentClass);
assertTrue(facade instanceof PersistentClassFacadeImpl);
assertSame(persistentClass, ((IFacade) facade).getTarget());
}
use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateEntityMetamodel.
@Test
public void testCreateEntityMetamodel() {
Configuration configuration = new Configuration();
final StandardServiceRegistryBuilder standardServiceRegistryBuilder = new StandardServiceRegistryBuilder();
standardServiceRegistryBuilder.applySetting(AvailableSettings.DIALECT, TestDialect.class.getName());
final StandardServiceRegistry serviceRegistry = standardServiceRegistryBuilder.build();
SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
RootClass rc = new RootClass();
SimpleValue sv = new SimpleValue(configuration.createMappings());
sv.setNullValue("null");
sv.setTypeName(Integer.class.getName());
rc.setIdentifier(sv);
rc.setOptimisticLockStyle(OptimisticLockStyle.NONE);
EntityMetamodel entityMetamodel = new EntityMetamodel(rc, null, sfi);
IEntityMetamodel facade = facadeFactory.createEntityMetamodel(entityMetamodel);
assertSame(entityMetamodel, ((IFacade) facade).getTarget());
}
Aggregations