Search in sources :

Example 1 with VersionBasicUserType

use of com.blazebit.persistence.view.spi.type.VersionBasicUserType in project blaze-persistence by Blazebit.

the class EntityViewUpdaterImpl method createVersionFlusher.

private VersionAttributeFlusher<Object, Object> createVersionFlusher(EntityViewManagerImpl evm, EntityType<?> entityType, AbstractMethodAttribute<?, ?> versionAttribute) {
    String attributeName = versionAttribute.getName();
    String attributeMapping = versionAttribute.getMapping();
    String parameterName = versionAttribute.getName();
    String updateFragment = versionAttribute.getMapping();
    AttributeAccessor viewAttributeAccessor = Accessors.forViewAttribute(evm, versionAttribute, false);
    AttributeAccessor attributeAccessor = Accessors.forEntityMapping(evm, versionAttribute);
    Type<?> type = ((com.blazebit.persistence.view.metamodel.SingularAttribute<?, ?>) versionAttribute).getType();
    @SuppressWarnings("unchecked") VersionBasicUserType<Object> userType = (VersionBasicUserType<Object>) ((BasicType<?>) type).getUserType();
    boolean jpaVersion = entityType.getSingularAttribute(versionAttribute.getMapping()).isVersion();
    return new VersionAttributeFlusher<>(attributeName, attributeMapping, userType, updateFragment, parameterName, attributeAccessor, viewAttributeAccessor, jpaVersion);
}
Also used : SingularAttribute(javax.persistence.metamodel.SingularAttribute) VersionBasicUserType(com.blazebit.persistence.view.spi.type.VersionBasicUserType) VersionAttributeFlusher(com.blazebit.persistence.view.impl.update.flush.VersionAttributeFlusher) InitialValueAttributeAccessor(com.blazebit.persistence.view.impl.accessor.InitialValueAttributeAccessor) AttributeAccessor(com.blazebit.persistence.view.impl.accessor.AttributeAccessor)

Aggregations

AttributeAccessor (com.blazebit.persistence.view.impl.accessor.AttributeAccessor)1 InitialValueAttributeAccessor (com.blazebit.persistence.view.impl.accessor.InitialValueAttributeAccessor)1 VersionAttributeFlusher (com.blazebit.persistence.view.impl.update.flush.VersionAttributeFlusher)1 VersionBasicUserType (com.blazebit.persistence.view.spi.type.VersionBasicUserType)1 SingularAttribute (javax.persistence.metamodel.SingularAttribute)1