Search in sources :

Example 61 with RootClass

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

the class PersistentClassFacadeTest method testIsRootClass.

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

Example 62 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 63 with RootClass

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

the class PersistentClassFacadeTest method testGetRootTable.

@Test
public void testGetRootTable() throws Exception {
    Field field = AbstractPersistentClassFacade.class.getDeclaredField("rootTable");
    field.setAccessible(true);
    assertNull(field.get(persistentClassFacade));
    Table tableTarget = new Table();
    ((RootClass) persistentClassTarget).setTable(tableTarget);
    ITable tableFacade = persistentClassFacade.getRootTable();
    assertSame(tableTarget, ((IFacade) tableFacade).getTarget());
    assertSame(tableFacade, field.get(persistentClassFacade));
}
Also used : RootClass(org.hibernate.mapping.RootClass) Field(java.lang.reflect.Field) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Test(org.junit.jupiter.api.Test)

Example 64 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(null);
    persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, persistentClassTarget);
}
Also used : RootClass(org.hibernate.mapping.RootClass) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 65 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