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());
}
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());
}
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());
}
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);
}
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);
}
}
}
Aggregations