Search in sources :

Example 11 with List

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

the class ValueFacadeTest method testSetIndex.

@Test
public void testSetIndex() {
    List valueTarget = new List(null, null);
    valueFacade = FACADE_FACTORY.createValue(valueTarget);
    Assert.assertNull(valueTarget.getIndex());
    SimpleValue indexTarget = new SimpleValue(null);
    IValue indexFacade = FACADE_FACTORY.createValue(indexTarget);
    valueFacade.setIndex(indexFacade);
    Assert.assertSame(indexTarget, valueTarget.getIndex());
}
Also used : IValue(org.jboss.tools.hibernate.runtime.spi.IValue) List(org.hibernate.mapping.List) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 12 with List

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

the class ValueFacadeTest method testSetIndex.

@Test
public void testSetIndex() {
    List valueTarget = new List(null, null);
    valueFacade = FACADE_FACTORY.createValue(valueTarget);
    Assert.assertNull(valueTarget.getIndex());
    SimpleValue indexTarget = new SimpleValue(null);
    IValue indexFacade = FACADE_FACTORY.createValue(indexTarget);
    valueFacade.setIndex(indexFacade);
    Assert.assertSame(indexTarget, valueTarget.getIndex());
}
Also used : IValue(org.jboss.tools.hibernate.runtime.spi.IValue) List(org.hibernate.mapping.List) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 13 with List

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

the class ValueFacadeTest method testIsList.

@Test
public void testIsList() {
    valueTarget = new SimpleValue(null);
    valueFacade = FACADE_FACTORY.createValue(valueTarget);
    Assert.assertFalse(valueFacade.isList());
    valueTarget = new List(null, null);
    valueFacade = FACADE_FACTORY.createValue(valueTarget);
    Assert.assertTrue(valueFacade.isList());
}
Also used : List(org.hibernate.mapping.List) SimpleValue(org.hibernate.mapping.SimpleValue) Test(org.junit.Test)

Example 14 with List

use of org.hibernate.mapping.List in project hibernate-orm by hibernate.

the class ValueVisitorTest method testProperCallbacks.

@Test
public void testProperCallbacks() {
    final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(serviceRegistry).buildMetadata();
    final Table tbl = new Table();
    final RootClass rootClass = new RootClass(metadataBuildingContext);
    ValueVisitor vv = new ValueVisitorValidator();
    MetadataBuildingContextTestingImpl metadataBuildingContext = new MetadataBuildingContextTestingImpl();
    new Any(metadataBuildingContext, tbl).accept(vv);
    new Array(metadataBuildingContext, rootClass).accept(vv);
    new Bag(metadataBuildingContext, rootClass).accept(vv);
    new Component(metadataBuildingContext, rootClass).accept(vv);
    new DependantValue(metadataBuildingContext, tbl, null).accept(vv);
    new IdentifierBag(metadataBuildingContext, rootClass).accept(vv);
    new List(metadataBuildingContext, rootClass).accept(vv);
    new ManyToOne(metadataBuildingContext, tbl).accept(vv);
    new Map(metadataBuildingContext, rootClass).accept(vv);
    new OneToMany(metadataBuildingContext, rootClass).accept(vv);
    new OneToOne(metadataBuildingContext, tbl, rootClass).accept(vv);
    new PrimitiveArray(metadataBuildingContext, rootClass).accept(vv);
    new Set(metadataBuildingContext, rootClass).accept(vv);
    new SimpleValue(metadataBuildingContext).accept(vv);
}
Also used : RootClass(org.hibernate.mapping.RootClass) Table(org.hibernate.mapping.Table) Set(org.hibernate.mapping.Set) ValueVisitor(org.hibernate.mapping.ValueVisitor) DependantValue(org.hibernate.mapping.DependantValue) MetadataSources(org.hibernate.boot.MetadataSources) Bag(org.hibernate.mapping.Bag) IdentifierBag(org.hibernate.mapping.IdentifierBag) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) IdentifierBag(org.hibernate.mapping.IdentifierBag) OneToMany(org.hibernate.mapping.OneToMany) Any(org.hibernate.mapping.Any) ManyToOne(org.hibernate.mapping.ManyToOne) SimpleValue(org.hibernate.mapping.SimpleValue) MetadataBuildingContextTestingImpl(org.hibernate.testing.boot.MetadataBuildingContextTestingImpl) Array(org.hibernate.mapping.Array) PrimitiveArray(org.hibernate.mapping.PrimitiveArray) OneToOne(org.hibernate.mapping.OneToOne) PrimitiveArray(org.hibernate.mapping.PrimitiveArray) List(org.hibernate.mapping.List) Component(org.hibernate.mapping.Component) Map(org.hibernate.mapping.Map) Test(org.junit.Test)

Example 15 with List

use of org.hibernate.mapping.List in project hibernate-orm by hibernate.

the class ClassesAuditingData method updateCalculatedProperty.

private void updateCalculatedProperty(String entityName, Property property, String propertyName, AuditedPropertiesHolder propertyHolder) {
    final PropertyAuditingData propertyAuditingData = propertyHolder.getPropertyAuditingData(propertyName);
    final boolean isAuditMappedBy = propertyAuditingData.getAuditMappedBy() != null;
    final boolean isRelationMappedBy = propertyAuditingData.getRelationMappedBy() != null;
    // handle updating the property, if applicable.
    if (isAuditMappedBy || isRelationMappedBy) {
        final String referencedEntityName = MappingTools.getReferencedEntityName(property.getValue());
        final ClassAuditingData referencedAuditData = entityNameToAuditingData.get(referencedEntityName);
        if (isAuditMappedBy) {
            // If a property had the @AuditMappedBy annotation, setting the referenced fields to be always insertable.
            setAuditMappedByInsertable(referencedEntityName, entityName, referencedAuditData, propertyAuditingData);
        } else if (isRelationMappedBy && (property.getValue() instanceof List)) {
            // If a property has mappedBy= and @Indexed and isn't @AuditMappedBy, add synthetic support.
            addSyntheticIndexProperty((List) property.getValue(), property.getPropertyAccessorName(), referencedAuditData);
        }
    }
    // This is useful for AuditMappedBy inside an Embeddable that holds a collection of entities.
    if (propertyAuditingData instanceof ComponentAuditingData) {
        final ComponentAuditingData componentAuditingData = (ComponentAuditingData) propertyAuditingData;
        final Component component = (Component) property.getValue();
        for (String componentPropertyName : componentAuditingData.getNonSyntheticPropertyNames()) {
            final Property componentProperty = component.getProperty(componentPropertyName);
            updateCalculatedProperty(entityName, componentProperty, componentPropertyName, componentAuditingData);
        }
    }
}
Also used : ClassAuditingData(org.hibernate.envers.configuration.internal.metadata.reader.ClassAuditingData) ComponentAuditingData(org.hibernate.envers.configuration.internal.metadata.reader.ComponentAuditingData) List(org.hibernate.mapping.List) PropertyAuditingData(org.hibernate.envers.configuration.internal.metadata.reader.PropertyAuditingData) Component(org.hibernate.mapping.Component) Property(org.hibernate.mapping.Property)

Aggregations

List (org.hibernate.mapping.List)27 SimpleValue (org.hibernate.mapping.SimpleValue)26 Test (org.junit.Test)25 IValue (org.jboss.tools.hibernate.runtime.spi.IValue)8 Component (org.hibernate.mapping.Component)2 OneToMany (org.hibernate.mapping.OneToMany)2 AnnotationException (org.hibernate.AnnotationException)1 MetadataSources (org.hibernate.boot.MetadataSources)1 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)1 PropertyHolder (org.hibernate.cfg.PropertyHolder)1 ClassAuditingData (org.hibernate.envers.configuration.internal.metadata.reader.ClassAuditingData)1 ComponentAuditingData (org.hibernate.envers.configuration.internal.metadata.reader.ComponentAuditingData)1 PropertyAuditingData (org.hibernate.envers.configuration.internal.metadata.reader.PropertyAuditingData)1 Any (org.hibernate.mapping.Any)1 Array (org.hibernate.mapping.Array)1 Bag (org.hibernate.mapping.Bag)1 Collection (org.hibernate.mapping.Collection)1 DependantValue (org.hibernate.mapping.DependantValue)1 IdentifierBag (org.hibernate.mapping.IdentifierBag)1 IndexBackref (org.hibernate.mapping.IndexBackref)1