微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javax.persistence.metamodel.Type的实例源码

项目:jpasecurity    文件TypeDeFinition.java   
public Attribute<?,?> filter() {
    Type<?> type = forModel(metamodel).filter(roottype);
    Attribute<?,?> result = null;
    for (int i = 1; i < pathelements.length; i++) {
        if (!(type instanceof ManagedType)) {
            throw new PersistenceException("Cannot navigate through simple property "
                    + pathelements[i] + " of type " + type.getJavaType());
        }
        result = ((ManagedType<?>)type).getAttribute(pathelements[i]);
        if (result.isCollection()) {
            type = ((PluralAttribute<?,?,?>)result).getElementType();
        } else {
            type = ((Singularattribute<?,?>)result).getType();
        }
    }
    return result;
}
项目:hibernate-semantic-query    文件Helper.java   
public static Type toType(Bindable bindable) {
    switch ( bindable.getBindableType() ) {
        case ENTITY_TYPE: {
            return (EntityType) bindable;
        }
        case SINGULAR_ATTRIBUTE: {
            return ( (Singularattribute) bindable ).getType();
        }
        case PLURAL_ATTRIBUTE: {
            return ( (PluralAttribute) bindable ).getElementType();
        }
        default: {
            throw new ParsingException( "Unexpected Bindable type : " + bindable );
        }
    }
}
项目:hibernate-semantic-query    文件AbstractIdentifiableType.java   
@Override
public Type<?> getIdType() {
    if ( getHierarchy().getIdentifierDescriptor() instanceof IdentifierDescriptorSingleAttribute ) {
        final Singularattribute idAttribute = ( (IdentifierDescriptorSingleAttribute) getHierarchy().getIdentifierDescriptor() )
                .getIdAttribute();
        if ( idAttribute instanceof SingularattributeBasic ) {
            return ( (SingularattributeBasic) idAttribute ).getormType();
        }
        else if ( idAttribute instanceof SingularattributeEmbedded ) {
            return ( (SingularattributeEmbedded) idAttribute ).getEmbeddablePersister();
        }
        else {
            throw new IllegalStateException( "Expected BASIC or EMbedDED attribute type for identifier" );
        }
    }
    return null;
}
项目:olingo-odata2    文件JPAEdmPropertyTest.java   
@Override
public Type<java.lang.String> getElementType() {
  return new Type<java.lang.String>() {

    @Override
    public Class<java.lang.String> getJavaType() {
      return java.lang.String.class;
    }

    @Override
    public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
      return null;
    }

  };
}
项目:jpasecurity    文件CriteriaEntityFilter.java   
private Path getSelectedpath(int index,javax.persistence.criteria.Path<?> path) {
    if (path.getParentPath() != null) {
        Type<?> type = getType(path.getModel());
        if (type.getPersistenceType() == PersistenceType.BASIC
            || type.getPersistenceType() == PersistenceType.EMbedDABLE) {
            return getSelectedpath(index,path.getParentPath());
        }
        return getSelectedpath(index,path.getParentPath()).append(getName(path.getModel()));
    }
    if (path.getAlias() == null) {
        path.alias("alias" + index);
    }
    return new Path(path.getAlias());
}
项目:jpasecurity    文件CriteriaEntityFilter.java   
private Class<?> getSelectedType(javax.persistence.criteria.Path<?> path) {
    Type<?> type = getType(path.getModel());
    if (type.getPersistenceType() == PersistenceType.BASIC
        || type.getPersistenceType() == PersistenceType.EMbedDABLE) {
        return getSelectedType(path.getParentPath());
    } else {
        return type.getJavaType();
    }
}
项目:query-utils    文件QueryUtils.java   
@SuppressWarnings("unchecked")
public static <R> Type<R> getElementType(Attribute<?,?> attr) {
    if (attr instanceof Singularattribute) {
        return ((Singularattribute<?,R>) attr).getType();
    } else {
        return ((PluralAttribute<?,R>)attr).getElementType();
    }
}
项目:Joiner    文件ReflectionUtils.java   
public static Set<Class> getSubclasses(Class<?> parent,EntityManager entityManager) {
    return entityManager.getmetamodel().getEntities().stream()
            .filter(entityType -> parent != entityType.getJavaType() && parent.isAssignableFrom(entityType.getJavaType()))
            .map(Type::getJavaType)
            .collect(Collectors.toCollection(HashSet::new));
}
项目:jpasecurity    文件EntityFilterTest.java   
@Before
public void initialize() throws ParseException,NoSuchMethodException {
    metamodel metamodel = mock(metamodel.class);
    SecurePersistenceUnitUtil persistenceUnitUtil = mock(SecurePersistenceUnitUtil.class);
    accessManager = mock(DefaultAccessManager.class);
    SecurityContext securityContext = mock(SecurityContext.class);
    EntityType entityType = mock(EntityType.class);
    Singularattribute idAttribute = mock(Singularattribute.class);
    Singularattribute nameAttribute = mock(Singularattribute.class);
    Singularattribute parentAttribute = mock(Singularattribute.class);
    PluralAttribute childrenAttribute = mock(PluralAttribute.class);
    MapAttribute relatedAttribute = mock(MapAttribute.class);
    Type integerType = mock(Type.class);
    when(metamodel.getEntities()).thenReturn(Collections.<EntityType<?>>singleton(entityType));
    when(metamodel.managedType(MethodAccesstestBean.class)).thenReturn(entityType);
    when(metamodel.entity(MethodAccesstestBean.class)).thenReturn(entityType);
    when(accessManager.getContext()).thenReturn(securityContext);
    when(securityContext.getAliases()).thenReturn(Collections.singleton(CURRENT_PRINCIPAL));
    when(securityContext.getAliasValue(CURRENT_PRINCIPAL)).thenReturn(NAME);
    when(entityType.getName()).thenReturn(MethodAccesstestBean.class.getSimpleName());
    when(entityType.getJavaType()).thenReturn((Class)MethodAccesstestBean.class);
    when(entityType.getAttributes()).thenReturn(new HashSet(Arrays.asList(
            idAttribute,nameAttribute,parentAttribute,childrenAttribute,relatedAttribute)));
    when(entityType.getAttribute("id")).thenReturn(idAttribute);
    when(entityType.getAttribute("name")).thenReturn(nameAttribute);
    when(entityType.getAttribute("parent")).thenReturn(parentAttribute);
    when(entityType.getAttribute("children")).thenReturn(childrenAttribute);
    when(entityType.getAttribute("related")).thenReturn(relatedAttribute);
    when(idAttribute.getName()).thenReturn("id");
    when(idAttribute.isCollection()).thenReturn(false);
    when(idAttribute.getType()).thenReturn(integerType);
    when(idAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.BASIC);
    when(idAttribute.getJavaType()).thenReturn(Integer.TYPE);
    when(idAttribute.getJavaMember()).thenReturn(MethodAccesstestBean.class.getDeclaredMethod("getId"));
    when(nameAttribute.getName()).thenReturn("name");
    when(nameAttribute.isCollection()).thenReturn(false);
    when(nameAttribute.getType()).thenReturn(integerType);
    when(nameAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.BASIC);
    when(nameAttribute.getJavaType()).thenReturn(String.class);
    when(nameAttribute.getJavaMember()).thenReturn(MethodAccesstestBean.class.getDeclaredMethod("getName"));
    when(parentAttribute.getName()).thenReturn("parent");
    when(parentAttribute.isCollection()).thenReturn(false);
    when(parentAttribute.getType()).thenReturn(entityType);
    when(parentAttribute.getPersistentAttributeType()).thenReturn(PersistentAttributeType.MANY_TO_ONE);
    when(parentAttribute.getJavaType()).thenReturn(MethodAccesstestBean.class);
    when(parentAttribute.getJavaMember()).thenReturn(MethodAccesstestBean.class.getDeclaredMethod("getParent"));
    when(childrenAttribute.getName()).thenReturn("children");
    when(childrenAttribute.isCollection()).thenReturn(true);
    when(childrenAttribute.getElementType()).thenReturn(entityType);
    when(childrenAttribute.getJavaMember())
        .thenReturn(MethodAccesstestBean.class.getDeclaredMethod("getChildren"));
    when(relatedAttribute.getName()).thenReturn("related");
    when(relatedAttribute.isCollection()).thenReturn(true);
    when(relatedAttribute.getKeyJavaType()).thenReturn(MethodAccesstestBean.class);
    when(relatedAttribute.getBindableJavaType()).thenReturn(MethodAccesstestBean.class);
    when(relatedAttribute.getElementType()).thenReturn(entityType);
    when(relatedAttribute.getJavaMember())
        .thenReturn(MethodAccesstestBean.class.getDeclaredMethod("getRelated"));

    entityFilter = new EntityFilter(metamodel,persistenceUnitUtil,initializeAccessRules(metamodel));
    DefaultAccessManager.Instance.register(accessManager);
}
项目:hibernate-semantic-query    文件CollectionPersisterImpl.java   
@Override
@SuppressWarnings("unchecked")
public Type<E> getElementType() {
    return getElementDescriptor();
}
项目:hibernate-semantic-query    文件SingularattributeEmbedded.java   
@Override
public Type getType() {
    return getEmbeddablePersister();
}
项目:hibernate-semantic-query    文件SingularattributeBasic.java   
@Override
public Type getType() {
    return getormType();
}
项目:olingo-odata2    文件JPAEntityTypeMock.java   
@Override
public Type<?> getIdType() {
  return null;
}
项目:olingo-odata2    文件JPAEntityTypeMock.java   
@Override
public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
  return null;
}
项目:olingo-odata2    文件JPASingularattributeMock.java   
@Override
public Type<T> getType() {
  return null;
}
项目:olingo-odata2    文件JPAPluralAttributeMock.java   
@Override
public Type<String> getElementType() {
  // Todo Auto-generated method stub
  return null;
}
项目:olingo-odata2    文件JPAEdmNavigationPropertyTest.java   
@Override
public Type<java.lang.String> getElementType() {
  return new ElementType();
}
项目:olingo-odata2    文件JPAEdmNavigationPropertyTest.java   
@Override
public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
  return PersistenceType.BASIC;
}
项目:stdlib    文件QEntity.java   
/**
 * Parse an @Entity
 *
 * @param entityFactory
 * @param Metadata
 * @param sessionFactory
 */
void parse(QEntityFactory entityFactory,EntityType<?> Metadata,SessionFactoryImplementor sessionFactory)
{
    this.metamodelEntity = Metadata;
    this.name = Metadata.getName();

    for (Attribute<?,?> attribute : Metadata.getAttributes())
    {
        parseFields(entityFactory,sessionFactory,null,attribute);
    }

    // Parse top-level properties

    // Add identifier property
    {
        if (!Metadata.hasSingleIdAttribute())
            throw new IllegalArgumentException("@IdClass Entity not supported! " + Metadata.getJavaType());

        Type idType = Metadata.getIdType();

        switch (idType.getPersistenceType())
        {
            case BASIC:
                break; // No action necessary,will be processed like a normal field
            case EMbedDABLE:
            {
                EmbeddableType<?> emb = (EmbeddableType<?>) idType;

                parseEmbeddable(entityFactory,"id",emb);
                break;
            }
            default:
                throw new IllegalArgumentException("Cannot handle id type: " + idType.getPersistenceType() + ": " + idType);
        }
    }

    // Add links to descendants
    {
        final List<QEntity> descendants = entityFactory.getSubclasses(clazz);

        if (!descendants.isEmpty())
            this.descendants = descendants;
    }


    // figure out the id method/field
    final String idPropertyName = getIdPropertyName();

    if (idPropertyName != null)
        this.idProperty = new PropertyWrapper(clazz,idPropertyName);
}
项目:query-utils    文件RelationSetAttribute.java   
@SuppressWarnings("unchecked")
public <E2 extends IEntity<?>> RelationSetAttribute(SetAttribute<? super E,? super E2> attribute,MetaJpaConstructor<? super E2,R,?> constructor) {
    super((A)(Object)attribute,CollectionType.SET,(Type<R>)attribute.getElementType());
    this.constructor = (MetaJpaConstructor<? extends IEntity<?>,?>) constructor;
}
项目:query-utils    文件AttributeProxy.java   
@Override
public Type<Y> getType() {
    return proxyTarget == null ? null :  proxyTarget.getType();
}
项目:query-utils    文件AttributeProxy.java   
PluralAttributeProxy(A proxyTarget,CollectionType ct,Type<Y> et) {
    super(proxyTarget);
    this.ct = ct;
    this.et = et;
}
项目:query-utils    文件AttributeProxy.java   
@Override
public Type<Y> getElementType() {
    return et;
}
项目:query-utils    文件RelationCollectionAttribute.java   
@SuppressWarnings("unchecked")
public <E2 extends IEntity<?>> RelationCollectionAttribute(CollectionAttribute<? super E,CollectionType.COLLECTION,?>) constructor;
}
项目:query-utils    文件RelationListAttribute.java   
@SuppressWarnings("unchecked")
public <E2 extends IEntity<?>> RelationListAttribute(ListAttribute<? super E,CollectionType.LIST,?>) constructor;
}
项目:cloud-odata-java    文件JPAEntityTypeMock.java   
@Override
public Type<?> getIdType() {
  return null;
}
项目:cloud-odata-java    文件JPAEntityTypeMock.java   
@Override
public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
  return null;
}
项目:cloud-odata-java    文件JPASingularattributeMock.java   
@Override
public Type<T> getType() {
  return null;
}
项目:cloud-odata-java    文件JPAPluralAttributeMock.java   
@Override
public Type<String> getElementType() {
  // Todo Auto-generated method stub
  return null;
}
项目:cloud-odata-java    文件JPAEdmNavigationPropertyTest.java   
@Override
public Type<java.lang.String> getElementType() {
  return new ElementType();
}
项目:cloud-odata-java    文件JPAEdmNavigationPropertyTest.java   
@Override
public javax.persistence.metamodel.Type.PersistenceType getPersistenceType() {
  return PersistenceType.BASIC;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。