Search in sources :

Example 41 with JoinedSubclass

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

the class ServiceImplTest method testNewJoinedSubclass.

@Test
public void testNewJoinedSubclass() {
    IPersistentClass persistentClass = service.newRootClass();
    IPersistentClass joinedSubclass = service.newJoinedSubclass(persistentClass);
    assertNotNull(joinedSubclass);
    Object target = ((IFacade) joinedSubclass).getTarget();
    assertNotNull(target);
    assertTrue(target instanceof JoinedSubclass);
    assertSame(persistentClass, joinedSubclass.getSuperclass());
    assertSame(((IFacade) persistentClass).getTarget(), ((JoinedSubclass) target).getSuperclass());
}
Also used : IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) JoinedSubclass(org.hibernate.mapping.JoinedSubclass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) Test(org.junit.jupiter.api.Test)

Example 42 with JoinedSubclass

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

the class ServiceImpl method newJoinedSubclass.

@Override
public IPersistentClass newJoinedSubclass(IPersistentClass persistentClass) {
    assert persistentClass instanceof IFacade;
    IPersistentClass result = facadeFactory.createPersistentClass(new JoinedSubclass((PersistentClass) ((IFacade) persistentClass).getTarget(), null));
    ((AbstractPersistentClassFacade) result).setSuperClass(persistentClass);
    return result;
}
Also used : AbstractPersistentClassFacade(org.jboss.tools.hibernate.runtime.common.AbstractPersistentClassFacade) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) JoinedSubclass(org.hibernate.mapping.JoinedSubclass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 43 with JoinedSubclass

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

the class ServiceImpl method newJoinedSubclass.

@Override
public IPersistentClass newJoinedSubclass(IPersistentClass persistentClass) {
    assert persistentClass instanceof IFacade;
    IPersistentClass result = facadeFactory.createPersistentClass(new JoinedSubclass((PersistentClass) ((IFacade) persistentClass).getTarget(), DummyMetadataBuildingContext.INSTANCE));
    ((AbstractPersistentClassFacade) result).setSuperClass(persistentClass);
    return result;
}
Also used : AbstractPersistentClassFacade(org.jboss.tools.hibernate.runtime.common.AbstractPersistentClassFacade) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) JoinedSubclass(org.hibernate.mapping.JoinedSubclass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PersistentClass(org.hibernate.mapping.PersistentClass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass)

Example 44 with JoinedSubclass

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

the class ServiceImplTest method testNewJoinedSubclass.

@Test
public void testNewJoinedSubclass() {
    IPersistentClass persistentClass = service.newRootClass();
    IPersistentClass joinedSubclass = service.newJoinedSubclass(persistentClass);
    assertNotNull(joinedSubclass);
    Object target = ((IFacade) joinedSubclass).getTarget();
    assertNotNull(target);
    assertTrue(target instanceof JoinedSubclass);
    assertSame(persistentClass, joinedSubclass.getSuperclass());
    assertSame(((IFacade) persistentClass).getTarget(), ((JoinedSubclass) target).getSuperclass());
}
Also used : IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) JoinedSubclass(org.hibernate.mapping.JoinedSubclass) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) Test(org.junit.jupiter.api.Test)

Example 45 with JoinedSubclass

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

the class PersistentClassFacadeTest method testIsJoinedSubclass.

@Test
public void testIsJoinedSubclass() {
    persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, new RootClass());
    assertFalse(persistentClassFacade.isJoinedSubclass());
    Table rootTable = new Table();
    Table subTable = new Table();
    RootClass rootClass = new RootClass();
    rootClass.setTable(rootTable);
    JoinedSubclass subclass = new JoinedSubclass(rootClass);
    subclass.setTable(subTable);
    persistentClassFacade = new PersistentClassFacadeImpl(FACADE_FACTORY, subclass);
    assertTrue(persistentClassFacade.isJoinedSubclass());
    subclass.setTable(rootTable);
    assertFalse(persistentClassFacade.isJoinedSubclass());
}
Also used : RootClass(org.hibernate.mapping.RootClass) ITable(org.jboss.tools.hibernate.runtime.spi.ITable) Table(org.hibernate.mapping.Table) JoinedSubclass(org.hibernate.mapping.JoinedSubclass) Test(org.junit.jupiter.api.Test)

Aggregations

JoinedSubclass (org.hibernate.mapping.JoinedSubclass)49 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)33 Test (org.junit.jupiter.api.Test)33 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)22 RootClass (org.hibernate.mapping.RootClass)14 PersistentClass (org.hibernate.mapping.PersistentClass)13 Table (org.hibernate.mapping.Table)12 AbstractPersistentClassFacade (org.jboss.tools.hibernate.runtime.common.AbstractPersistentClassFacade)11 ITable (org.jboss.tools.hibernate.runtime.spi.ITable)11 Iterator (java.util.Iterator)2 AnnotationException (org.hibernate.AnnotationException)2 DependantValue (org.hibernate.mapping.DependantValue)2 SimpleValue (org.hibernate.mapping.SimpleValue)2 Subclass (org.hibernate.mapping.Subclass)2 UnionSubclass (org.hibernate.mapping.UnionSubclass)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 CollectionTable (javax.persistence.CollectionTable)1 Entity (javax.persistence.Entity)1 JoinTable (javax.persistence.JoinTable)1