Search in sources :

Example 1 with EnhancedUserType

use of org.hibernate.usertype.EnhancedUserType in project blaze-persistence by Blazebit.

the class HibernateJpaProvider method supportsEnumLiteral.

@Override
public boolean supportsEnumLiteral(ManagedType<?> ownerType, String attributeName, boolean key) {
    if (ownerType instanceof EntityType<?>) {
        AbstractEntityPersister entityPersister = getEntityPersister(ownerType);
        Type propertyType;
        propertyType = getPropertyType(entityPersister, attributeName);
        if (propertyType instanceof CollectionType) {
            CollectionPersister collectionPersister = entityPersister.getFactory().getCollectionPersister(((CollectionType) propertyType).getRole());
            if (key) {
                propertyType = collectionPersister.getIndexType();
            } else {
                propertyType = collectionPersister.getElementType();
            }
        }
        if (propertyType instanceof CustomType) {
            return ((CustomType) propertyType).getUserType() instanceof EnhancedUserType;
        }
        return false;
    }
    return true;
}
Also used : EntityType(javax.persistence.metamodel.EntityType) CustomType(org.hibernate.type.CustomType) EnhancedUserType(org.hibernate.usertype.EnhancedUserType) ManyToOneType(org.hibernate.type.ManyToOneType) OneToOneType(org.hibernate.type.OneToOneType) IdentifiableType(javax.persistence.metamodel.IdentifiableType) JoinType(com.blazebit.persistence.JoinType) ManagedType(javax.persistence.metamodel.ManagedType) EnhancedUserType(org.hibernate.usertype.EnhancedUserType) CustomType(org.hibernate.type.CustomType) CollectionType(org.hibernate.type.CollectionType) EmbeddedComponentType(org.hibernate.type.EmbeddedComponentType) EntityType(javax.persistence.metamodel.EntityType) ComponentType(org.hibernate.type.ComponentType) CompositeType(org.hibernate.type.CompositeType) AssociationType(org.hibernate.type.AssociationType) Type(org.hibernate.type.Type) CollectionPersister(org.hibernate.persister.collection.CollectionPersister) CollectionType(org.hibernate.type.CollectionType) AbstractEntityPersister(org.hibernate.persister.entity.AbstractEntityPersister)

Aggregations

JoinType (com.blazebit.persistence.JoinType)1 EntityType (javax.persistence.metamodel.EntityType)1 IdentifiableType (javax.persistence.metamodel.IdentifiableType)1 ManagedType (javax.persistence.metamodel.ManagedType)1 CollectionPersister (org.hibernate.persister.collection.CollectionPersister)1 AbstractEntityPersister (org.hibernate.persister.entity.AbstractEntityPersister)1 AssociationType (org.hibernate.type.AssociationType)1 CollectionType (org.hibernate.type.CollectionType)1 ComponentType (org.hibernate.type.ComponentType)1 CompositeType (org.hibernate.type.CompositeType)1 CustomType (org.hibernate.type.CustomType)1 EmbeddedComponentType (org.hibernate.type.EmbeddedComponentType)1 ManyToOneType (org.hibernate.type.ManyToOneType)1 OneToOneType (org.hibernate.type.OneToOneType)1 Type (org.hibernate.type.Type)1 EnhancedUserType (org.hibernate.usertype.EnhancedUserType)1