Search in sources :

Example 46 with RootClass

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

the class PropertyFacadeTest method testIsComposite.

@Test
public void testIsComposite() {
    propertyTarget.setValue(createValue());
    assertFalse(propertyFacade.isComposite());
    MetadataImplementor metadataImplementor = createMetadataImplementor();
    Component component = new Component(metadataImplementor, new Table(), new RootClass(null));
    propertyTarget.setValue(component);
    assertTrue(propertyFacade.isComposite());
}
Also used : RootClass(org.hibernate.mapping.RootClass) Table(org.hibernate.mapping.Table) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) Component(org.hibernate.mapping.Component) Test(org.junit.jupiter.api.Test)

Example 47 with RootClass

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

the class PropertyFacadeTest method testGetPersistentClass.

@Test
public void testGetPersistentClass() throws Exception {
    Field field = AbstractPropertyFacade.class.getDeclaredField("persistentClass");
    field.setAccessible(true);
    assertNull(field.get(propertyFacade));
    assertNull(propertyFacade.getPersistentClass());
    PersistentClass persistentClassTarget = new RootClass(null);
    propertyTarget.setPersistentClass(persistentClassTarget);
    IPersistentClass persistentClassFacade = propertyFacade.getPersistentClass();
    assertNotNull(persistentClassFacade);
    assertSame(persistentClassFacade, field.get(propertyFacade));
    assertSame(persistentClassTarget, ((IFacade) persistentClassFacade).getTarget());
}
Also used : RootClass(org.hibernate.mapping.RootClass) Field(java.lang.reflect.Field) 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 48 with RootClass

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

the class Cfg2HbmToolFacadeTest method testGetTagProperty.

@Test
public void testGetTagProperty() throws Exception {
    RootClass rc = new RootClass(null);
    Property p = new Property();
    Table t = new Table();
    SimpleValue sv = new SimpleValue(createMetadaImplementor(), t);
    sv.setTypeName("foobar");
    p.setValue(sv);
    p.setPersistentClass(rc);
    rc.setVersion(p);
    IProperty property = new AbstractPropertyFacade(FACADE_FACTORY, p) {
    };
    assertEquals("version", cfg2HbmToolFacade.getTag(property));
}
Also used : RootClass(org.hibernate.mapping.RootClass) Table(org.hibernate.mapping.Table) AbstractPropertyFacade(org.jboss.tools.hibernate.runtime.common.AbstractPropertyFacade) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) Property(org.hibernate.mapping.Property) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.jupiter.api.Test)

Example 49 with RootClass

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

the class ConfigurationFacadeTest method testGetClassMapping.

@Test
public void testGetClassMapping() throws Exception {
    PersistentClass persistentClass = new RootClass(null);
    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);
    Field addedClassesField = ConfigurationFacadeImpl.class.getDeclaredField("addedClasses");
    addedClassesField.setAccessible(true);
    @SuppressWarnings("unchecked") List<IPersistentClass> addedClasses = (List<IPersistentClass>) addedClassesField.get(configurationFacade);
    addedClasses.add(persistentClassFacade);
    assertSame(configurationFacade.getClassMapping("Foo"), persistentClassFacade);
}
Also used : RootClass(org.hibernate.mapping.RootClass) Field(java.lang.reflect.Field) List(java.util.List) 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 50 with RootClass

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

the class FacadeFactoryTest method testCreateEntityMetamodel.

@Test
public void testCreateEntityMetamodel() {
    final StandardServiceRegistryBuilder standardServiceRegistryBuilder = new StandardServiceRegistryBuilder();
    standardServiceRegistryBuilder.applySetting(AvailableSettings.DIALECT, TestDialect.class.getName());
    final StandardServiceRegistry serviceRegistry = standardServiceRegistryBuilder.build();
    final MetadataSources mds = new MetadataSources(serviceRegistry);
    Metadata md = mds.buildMetadata();
    SessionFactoryImplementor sfi = (SessionFactoryImplementor) md.buildSessionFactory();
    RootClass rc = new RootClass(null);
    SimpleValue sv = new SimpleValue((MetadataImplementor) md);
    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());
}
Also used : RootClass(org.hibernate.mapping.RootClass) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) MetadataSources(org.hibernate.boot.MetadataSources) ClassMetadata(org.hibernate.metadata.ClassMetadata) IClassMetadata(org.jboss.tools.hibernate.runtime.spi.IClassMetadata) Metadata(org.hibernate.boot.Metadata) CollectionMetadata(org.hibernate.metadata.CollectionMetadata) ICollectionMetadata(org.jboss.tools.hibernate.runtime.spi.ICollectionMetadata) IEntityMetamodel(org.jboss.tools.hibernate.runtime.spi.IEntityMetamodel) IEntityMetamodel(org.jboss.tools.hibernate.runtime.spi.IEntityMetamodel) EntityMetamodel(org.hibernate.tuple.entity.EntityMetamodel) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) 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