Search in sources :

Example 1 with OneToOnePrimaryKeyJoinColumnMapper

use of org.hibernate.envers.internal.entities.mapper.relation.OneToOnePrimaryKeyJoinColumnMapper in project hibernate-orm by hibernate.

the class ToOneRelationMetadataGenerator method addOneToOnePrimaryKeyJoinColumn.

@SuppressWarnings({ "unchecked" })
void addOneToOnePrimaryKeyJoinColumn(PropertyAuditingData propertyAuditingData, Value value, CompositeMapperBuilder mapper, String entityName, boolean insertable) {
    final String referencedEntityName = ((ToOne) value).getReferencedEntityName();
    final IdMappingData idMapping = mainGenerator.getReferencedIdMappingData(entityName, referencedEntityName, propertyAuditingData, true);
    final String lastPropertyPrefix = MappingTools.createToOneRelationPrefix(propertyAuditingData.getName());
    // Generating the id mapper for the relation
    final IdMapper relMapper = idMapping.getIdMapper().prefixMappedProperties(lastPropertyPrefix);
    // Storing information about this relation
    mainGenerator.getEntitiesConfigurations().get(entityName).addToOneRelation(propertyAuditingData.getName(), referencedEntityName, relMapper, insertable, MappingTools.ignoreNotFound(value));
    // Adding mapper for the id
    final PropertyData propertyData = propertyAuditingData.getPropertyData();
    mapper.addComposite(propertyData, new OneToOnePrimaryKeyJoinColumnMapper(entityName, referencedEntityName, propertyData, mainGenerator.getServiceRegistry()));
}
Also used : PropertyData(org.hibernate.envers.internal.entities.PropertyData) OneToOnePrimaryKeyJoinColumnMapper(org.hibernate.envers.internal.entities.mapper.relation.OneToOnePrimaryKeyJoinColumnMapper) OneToOne(org.hibernate.mapping.OneToOne) ToOne(org.hibernate.mapping.ToOne) IdMapper(org.hibernate.envers.internal.entities.mapper.id.IdMapper) ToOneIdMapper(org.hibernate.envers.internal.entities.mapper.relation.ToOneIdMapper) IdMappingData(org.hibernate.envers.internal.entities.IdMappingData)

Aggregations

IdMappingData (org.hibernate.envers.internal.entities.IdMappingData)1 PropertyData (org.hibernate.envers.internal.entities.PropertyData)1 IdMapper (org.hibernate.envers.internal.entities.mapper.id.IdMapper)1 OneToOnePrimaryKeyJoinColumnMapper (org.hibernate.envers.internal.entities.mapper.relation.OneToOnePrimaryKeyJoinColumnMapper)1 ToOneIdMapper (org.hibernate.envers.internal.entities.mapper.relation.ToOneIdMapper)1 OneToOne (org.hibernate.mapping.OneToOne)1 ToOne (org.hibernate.mapping.ToOne)1