Search in sources :

Example 76 with RootClass

use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.

the class ConfigurationFacadeTest method testAddClass.

@Test
public void testAddClass() {
    PersistentClass persistentClass = new RootClass(DummyMetadataBuildingContext.INSTANCE);
    persistentClass.setEntityName("Foo");
    IPersistentClass persistentClassFacade = FACADE_FACTORY.createPersistentClass(persistentClass);
    assertFalse(((ConfigurationFacadeImpl) configurationFacade).addedClasses.contains(persistentClassFacade));
    configurationFacade.addClass(persistentClassFacade);
    assertTrue(((ConfigurationFacadeImpl) configurationFacade).addedClasses.contains(persistentClassFacade));
}
Also used : RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) Test(org.junit.jupiter.api.Test) MetadataHelperTest(org.jboss.tools.hibernate.runtime.v_6_0.internal.util.MetadataHelperTest)

Example 77 with RootClass

use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.

the class ConfigurationFacadeTest method testGetClassMapping.

@Test
public void testGetClassMapping() {
    PersistentClass persistentClass = new RootClass(DummyMetadataBuildingContext.INSTANCE);
    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);
    ((ConfigurationFacadeImpl) configurationFacade).addedClasses.add(persistentClassFacade);
    assertSame(configurationFacade.getClassMapping("Foo"), persistentClassFacade);
}
Also used : RootClass(org.hibernate.mapping.RootClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) Test(org.junit.jupiter.api.Test) MetadataHelperTest(org.jboss.tools.hibernate.runtime.v_6_0.internal.util.MetadataHelperTest)

Example 78 with RootClass

use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.

the class FacadeFactoryTest method testCreateSpecialRootClass.

@Test
public void testCreateSpecialRootClass() {
    Property target = new Property();
    PersistentClass pc = new RootClass(DummyMetadataBuildingContext.INSTANCE);
    target.setPersistentClass(pc);
    IProperty property = facadeFactory.createProperty(target);
    IPersistentClass specialRootClass = facadeFactory.createSpecialRootClass(property);
    assertNotNull(specialRootClass);
    Object object = ((IFacade) specialRootClass).getTarget();
    assertTrue(specialRootClass instanceof SpecialRootClassFacadeImpl);
    assertTrue(object instanceof RootClass);
    assertSame(property, specialRootClass.getProperty());
}
Also used : RootClass(org.hibernate.mapping.RootClass) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Property(org.hibernate.mapping.Property) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) Test(org.junit.jupiter.api.Test)

Example 79 with RootClass

use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.

the class ValueFacadeTest method testGetOwner.

@Test
public void testGetOwner() {
    RootClass rc = new RootClass(null);
    Component componentTarget = new Component(DummyMetadataBuildingContext.INSTANCE, rc);
    valueFacade = FACADE_FACTORY.createValue(componentTarget);
    assertSame(rc, ((IFacade) valueFacade.getOwner()).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) Component(org.hibernate.mapping.Component) Test(org.junit.jupiter.api.Test)

Example 80 with RootClass

use of org.hibernate.mapping.RootClass in project jbosstools-hibernate by jbosstools.

the class ValueFacadeTest method testIsToOne.

@Test
public void testIsToOne() {
    valueTarget = new SimpleValue(DummyMetadataBuildingContext.INSTANCE, null);
    valueFacade = FACADE_FACTORY.createValue(valueTarget);
    assertFalse(valueFacade.isToOne());
    ToOne toOne = new OneToOne(DummyMetadataBuildingContext.INSTANCE, null, new RootClass(null));
    valueFacade = FACADE_FACTORY.createValue(toOne);
    assertTrue(valueFacade.isToOne());
}
Also used : RootClass(org.hibernate.mapping.RootClass) OneToOne(org.hibernate.mapping.OneToOne) ToOne(org.hibernate.mapping.ToOne) ManyToOne(org.hibernate.mapping.ManyToOne) OneToOne(org.hibernate.mapping.OneToOne) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.jupiter.api.Test)

Aggregations

RootClass (org.hibernate.mapping.RootClass)609 Test (org.junit.jupiter.api.Test)471 PersistentClass (org.hibernate.mapping.PersistentClass)166 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)162 Field (java.lang.reflect.Field)149 SimpleValue (org.hibernate.mapping.SimpleValue)142 Table (org.hibernate.mapping.Table)136 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)130 Property (org.hibernate.mapping.Property)124 Component (org.hibernate.mapping.Component)109 Column (org.hibernate.mapping.Column)53 ArrayList (java.util.ArrayList)51 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)51 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)44 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)43 Configuration (org.hibernate.cfg.Configuration)37 OneToOne (org.hibernate.mapping.OneToOne)37 MetadataSources (org.hibernate.boot.MetadataSources)35 Test (org.junit.Test)35 SingleTableSubclass (org.hibernate.mapping.SingleTableSubclass)34