Search in sources :

Example 91 with RootClass

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

the class PersistentClassFacadeTest method testGetJoinIterator.

@Test
public void testGetJoinIterator() throws Exception {
    Join join = new Join();
    Field field = AbstractPersistentClassFacade.class.getDeclaredField("joins");
    field.setAccessible(true);
    assertNull(field.get(persistentClassFacade));
    Iterator<IJoin> joinIterator = persistentClassFacade.getJoinIterator();
    assertNotNull(field.get(persistentClassFacade));
    assertTrue(((HashSet<?>) field.get(persistentClassFacade)).isEmpty());
    assertFalse(joinIterator.hasNext());
    field.set(persistentClassFacade, null);
    ((RootClass) persistentClassTarget).addJoin(join);
    joinIterator = persistentClassFacade.getJoinIterator();
    assertTrue(joinIterator.hasNext());
    assertSame(join, ((IFacade) joinIterator.next()).getTarget());
    assertFalse(joinIterator.hasNext());
}
Also used : RootClass(org.hibernate.mapping.RootClass) Field(java.lang.reflect.Field) Join(org.hibernate.mapping.Join) IJoin(org.jboss.tools.hibernate.runtime.spi.IJoin) IJoin(org.jboss.tools.hibernate.runtime.spi.IJoin) Test(org.junit.jupiter.api.Test)

Example 92 with RootClass

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

the class PersistentClassFacadeTest method testIsAssignableToRootClass.

@Test
public void testIsAssignableToRootClass() {
    persistentClassTarget = new SingleTableSubclass(new RootClass());
    persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, persistentClassTarget);
    assertFalse(persistentClassFacade.isAssignableToRootClass());
    persistentClassTarget = new RootClass();
    persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, persistentClassTarget);
    assertTrue(persistentClassFacade.isAssignableToRootClass());
}
Also used : RootClass(org.hibernate.mapping.RootClass) SingleTableSubclass(org.hibernate.mapping.SingleTableSubclass) Test(org.junit.jupiter.api.Test)

Example 93 with RootClass

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

the class PersistentClassFacadeTest method beforeEach.

@BeforeEach
public void beforeEach() {
    persistentClassTarget = new RootClass();
    persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, persistentClassTarget);
}
Also used : RootClass(org.hibernate.mapping.RootClass) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 94 with RootClass

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

the class PersistentClassFacadeTest method testGetPropertyClosureIterator.

@Test
public void testGetPropertyClosureIterator() throws Exception {
    Property propertyTarget = new Property();
    PersistentClass persistentClass = new RootClass() {

        private static final long serialVersionUID = 1L;

        @Override
        public Iterator<?> getPropertyClosureIterator() {
            HashSet<Property> set = new HashSet<Property>();
            set.add(propertyTarget);
            return set.iterator();
        }
    };
    persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, persistentClass);
    Field field = AbstractPersistentClassFacade.class.getDeclaredField("propertyClosures");
    field.setAccessible(true);
    assertNull(field.get(persistentClassFacade));
    Iterator<IProperty> iterator = persistentClassFacade.getPropertyClosureIterator();
    assertNotNull(field.get(persistentClassFacade));
    assertTrue(iterator.hasNext());
    assertSame(propertyTarget, ((IFacade) iterator.next()).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) Field(java.lang.reflect.Field) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) Property(org.hibernate.mapping.Property) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) PersistentClass(org.hibernate.mapping.PersistentClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 95 with RootClass

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

the class PersistentClassFacadeTest method testGetDiscriminator.

@Test
public void testGetDiscriminator() throws Exception {
    Value valueTarget = createValue();
    Field field = AbstractPersistentClassFacade.class.getDeclaredField("discriminator");
    field.setAccessible(true);
    assertNull(field.get(persistentClassFacade));
    assertNull(persistentClassFacade.getDiscriminator());
    assertNull(field.get(persistentClassFacade));
    ((RootClass) persistentClassTarget).setDiscriminator(valueTarget);
    IValue valueFacade = persistentClassFacade.getDiscriminator();
    assertNotNull(valueFacade);
    assertSame(valueFacade, field.get(persistentClassFacade));
    assertSame(valueTarget, ((IFacade) valueFacade).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) Field(java.lang.reflect.Field) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) IValue(org.jboss.tools.hibernate.runtime.spi.IValue) Value(org.hibernate.mapping.Value) KeyValue(org.hibernate.mapping.KeyValue) 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