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

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

项目:oma-riista-web    文件CriteriaUtils.java   
@Override
public Method load(final PluralAttribute<?,?,?> attribute) {
    final Class<?> declaringClass = attribute.getDeclaringType().getJavaType();
    final String getterName = getGetterName(attribute);
    final Method readMethod = BeanUtils.findDeclaredMethod(declaringClass,getterName);

    if (readMethod == null) {
        throw new IllegalStateException(String.format(
                "Class %s does not declare method named '%s'",declaringClass.getName(),getterName));
    }

    readMethod.setAccessible(true);
    return readMethod;
}
项目:oma-riista-web    文件CriteriaUtils.java   
@Nonnull
static <T,U,C extends Collection<U>> Function<T,C> jpaCollection(
        @Nonnull final PluralAttribute<? super T,C,U> attribute) {

    Objects.requireNonNull(attribute);

    final Class<C> collectionType = attribute.getJavaType();

    try {
        final Method readMethod = ENTITY_COLLECTION_GETTERS.get(attribute);

        return obj -> invokeAndCast(readMethod,obj,collectionType);

    } catch (final ExecutionException e) {
        throw new RuntimeException(e);
    }
}
项目:oma-riista-web    文件CriteriaUtils.java   
public static <T,C extends Collection<U>> void updateInverseCollection(
        @Nonnull final PluralAttribute<? super T,U> inverseAttribute,@Nonnull final U entity,@Nullable final T currentAssociation,@Nullable final T newAssociation) {

    Objects.requireNonNull(inverseAttribute,"inverseAttribute is null");
    Objects.requireNonNull(entity,"entity is null");

    final Function<T,C> fn = getCollectionIfInitialized(inverseAttribute);

    final C oldCollection = fn.apply(currentAssociation);

    if (oldCollection != null) {
        oldCollection.remove(entity);
    }

    final C newCollection = fn.apply(newAssociation);

    if (newCollection != null) {
        newCollection.add(entity);
    }
}
项目:oma-riista-web    文件CriteriaUtils.java   
@SuppressWarnings("unchecked")
@Nonnull
public static <T,U> Join<T,U> join(
        @Nonnull final From<?,T> from,@Nonnull final PluralAttribute<? super T,U> attribute) {

    Objects.requireNonNull(from,"from is null");
    Objects.requireNonNull(attribute,"attribute is null");

    if (attribute instanceof CollectionAttribute) {
        return from.join((CollectionAttribute<T,U>) attribute);
    }
    if (attribute instanceof SetAttribute) {
        return from.join((SetAttribute<T,U>) attribute);
    }
    if (attribute instanceof ListAttribute) {
        return from.join((ListAttribute<T,U>) attribute);
    }
    if (attribute instanceof MapAttribute) {
        return from.join((MapAttribute<T,U>) attribute);
    }

    // Should never end up here.
    throw new IllegalArgumentException();
}
项目:jhipster-stormpath-example    文件CacheConfiguration.java   
@Bean
public CacheManager cacheManager(JHipsterProperties jHipsterProperties) {
    log.debug("Starting Ehcache");
    cacheManager = net.sf.ehcache.CacheManager.create();
    cacheManager.getConfiguration().setMaxBytesLocalHeap(jHipsterProperties.getCache().getEhcache().getMaxBytesLocalHeap());
    log.debug("Registering Ehcache Metrics gauges");
    Set<EntityType<?>> entities = entityManager.getmetamodel().getEntities();
    for (EntityType<?> entity : entities) {
        String name = entity.getName();
        if (name == null || entity.getJavaType() != null) {
            name = entity.getJavaType().getName();
        }
        Assert.notNull(name,"entity cannot exist without an identifier");
        reconfigureCache(name,jHipsterProperties);
        for (PluralAttribute pluralAttribute : entity.getPluralAttributes()) {
            reconfigureCache(name + "." + pluralAttribute.getName(),jHipsterProperties);
        }
    }
    EhCacheCacheManager ehCacheManager = new EhCacheCacheManager();
    ehCacheManager.setCacheManager(cacheManager);
    return ehCacheManager;
}
项目: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;
}
项目:jpasecurity    文件MappingEvaluator.java   
public boolean visitJoin(Node node,Set<TypeDeFinition> typeDeFinitions) {
    if (node.jjtGetNumChildren() != 2) {
        return false;
    }
    Node pathNode = node.jjtGetChild(0);
    Node aliasNode = node.jjtGetChild(1);
    Alias rootAlias = new Alias(pathNode.jjtGetChild(0).toString());
    Class<?> roottype = getType(rootAlias,typeDeFinitions);
    ManagedType<?> managedType = forModel(metamodel).filter(roottype);
    for (int i = 1; i < pathNode.jjtGetNumChildren(); i++) {
        Attribute<?,?> attribute = managedType.getAttribute(pathNode.jjtGetChild(i).toString());
        if (attribute.getPersistentAttributeType() == PersistentAttributeType.BASIC) {
            throw new PersistenceException("Cannot navigate through basic property "
                    + pathNode.jjtGetChild(i) + " of path " + pathNode);
        }
        if (attribute.isCollection()) {
            PluralAttribute<?,?> pluralAttribute = (PluralAttribute<?,?>)attribute;
            managedType = (ManagedType<?>)pluralAttribute.getElementType();
        } else {
            managedType = (ManagedType<?>)((Singularattribute)attribute).getType();
        }
    }
    typeDeFinitions.add(new TypeDeFinition(new Alias(aliasNode.toString()),managedType.getJavaType()));
    return false;
}
项目: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    文件AbstractFromImpl.java   
@Override
    public <Y> JpaFetch<X,Y> fetch(PluralAttribute<? super X,Y> pluralAttribute,JoinType jt) {
//      if ( !canBeFetchSource() ) {
//          throw illegalFetch();
//      }
//
//      final Fetch<X,Y> fetch;
//      // Todo : combine Fetch and Join hierarchies (JoinImplementor extends Join,Fetch???)
//      if ( PluralAttribute.CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
//          fetch = constructJoin( (CollectionAttribute<X,Y>) pluralAttribute,jt );
//      }
//      else if ( PluralAttribute.CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
//          fetch = constructJoin( (ListAttribute<X,jt );
//      }
//      else if ( PluralAttribute.CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
//          fetch = constructJoin( (SetAttribute<X,jt );
//      }
//      else {
//          fetch = constructJoin( (MapAttribute<X,jt );
//      }
//      joinScope.addFetch( fetch );
//      return fetch;

        throw new NotYetImplementedException(  );
    }
项目:hibernate-semantic-query    文件AbstractPathImpl.java   
@Override
    @SuppressWarnings({ "unchecked" })
    public <E,C extends Collection<E>> JpaExpression<C> get(PluralAttribute<X,E> attribute) {
//      if ( ! canbedereferenced() ) {
//          throw illegalDereference();
//      }
//
//      PluralAttributePath<C> path = (PluralAttributePath<C>) resolveCachedAttributePath( attribute.getName() );
//      if ( path == null ) {
//          path = new PluralAttributePath<C>( criteriaBuilder(),this,attribute );
//          registerattributePath( attribute.getName(),path );
//      }
//      return path;

        throw new NotYetImplementedException(  );
    }
项目:javaee-lab    文件JpaUtil.java   
@SuppressWarnings("unchecked")
public <E,F> Path<F> getPath(Root<E> root,List<Attribute<?,?>> attributes) {
    Path<?> path = root;
    for (Attribute<?,?> attribute : attributes) {
        boolean found = false;
        if (path instanceof FetchParent) {
            for (Fetch<E,?> fetch : ((FetchParent<?,E>) path).getFetches()) {
                if (attribute.getName().equals(fetch.getAttribute().getName()) && (fetch instanceof Join<?,?>)) {
                    path = (Join<E,?>) fetch;
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            if (attribute instanceof PluralAttribute) {
                path = ((From<?,?>) path).join(attribute.getName(),JoinType.LEFT);
            } else {
                path = path.get(attribute.getName());
            }
        }
    }
    return (Path<F>) path;
}
项目:javaee-lab    文件JpaUtil.java   
public void verifyPath(List<Attribute<?,?>> path) {
    List<Attribute<?,?>> attributes = newArrayList(path);
    Class<?> from = null;
    if (attributes.get(0).isCollection()) {
        from = ((PluralAttribute) attributes.get(0)).getElementType().getJavaType();
    } else {
        from = attributes.get(0).getJavaType();
    }
    attributes.remove(0);
    for (Attribute<?,?> attribute : attributes) {
        if (!attribute.getDeclaringType().getJavaType().isAssignableFrom(from)) {
            throw new IllegalStateException("Wrong path.");
        }
        from = attribute.getJavaType();
    }
}
项目:javaee-lab    文件GenericRepository.java   
@SuppressWarnings({"unchecked","rawtypes"})
protected void fetches(SearchParameters sp,Root<E> root) {
    for (List<Attribute<?,?>> args : sp.getFetches()) {
        FetchParent<?,?> from = root;
        for (Attribute<?,?> arg : args) {
            boolean found = false;
            for (Fetch<?,?> fetch : from.getFetches()) {
                if (arg.equals(fetch.getAttribute())) {
                    from = fetch;
                    found = true;
                    break;
                }
            }
            if (!found) {
                if (arg instanceof PluralAttribute) {
                    from = from.fetch((PluralAttribute) arg,JoinType.LEFT);
                } else {
                    from = from.fetch((Singularattribute) arg,JoinType.LEFT);
                }
            }
        }
    }
}
项目:javaee-lab    文件metamodelUtil.java   
public List<Attribute<?,?>> toAttributes(String path,Class<?> from) {
    try {
        List<Attribute<?,?>> attributes = newArrayList();
        Class<?> current = from;
        for (String pathItem : Splitter.on(".").split(path)) {
            Class<?> metamodelClass = getCachedClass(current);
            Field field = metamodelClass.getField(pathItem);
            Attribute<?,?> attribute = (Attribute<?,?>) field.get(null);
            attributes.add(attribute);
            if (attribute instanceof PluralAttribute) {
                current = ((PluralAttribute<?,?>) attribute).getElementType().getJavaType();
            } else {
                current = attribute.getJavaType();
            }
        }
        return attributes;
    } catch (Exception e) {
        throw new IllegalArgumentException(e);
    }
}
项目:jpasearch    文件JpaUtil.java   
@SuppressWarnings({ "unchecked","rawtypes" })
public <E> void fetches(SearchParameters<E> sp,Root<E> root) {
    for (jpasearch.repository.query.Path<E,?> path : sp.getFetches()) {
        FetchParent<?,?> arg : metamodelUtil.toAttributes(root.getJavaType(),path.getPath())) {
            boolean found = false;
            for (Fetch<?,JoinType.LEFT);
                }
            }
        }
    }
}
项目:jpasearch    文件metamodelUtil.java   
public List<Attribute<?,?>> toAttributes(Class<?> from,String path) {
    try {
        List<Attribute<?,?>> attributes = new ArrayList<>();
        Class<?> current = from;
        for (String pathItem : Splitter.on(".").split(path)) {
            Class<?> metamodelClass = metamodelCache.get(current);
            Field field = metamodelClass.getField(pathItem);
            Attribute<?,?>) attribute).getElementType().getJavaType();
            } else {
                current = attribute.getJavaType();
            }
        }
        return attributes;
    } catch (Exception e) {
        throw new IllegalArgumentException(e);
    }
}
项目:jfbdemo    文件FilterCriteriaBuilder.java   
/**
 * This clumsy code is just to get the class of plural attribute mapping
 *
 * @param et
 * @param fieldName
 * @return
 */
private Class<?> getPluralJavaType(EntityType<?> et,String fieldName) {
    for (PluralAttribute pa : et.getPluralAttributes()) {
        if (pa.getName().equals(fieldName)) {
            switch (pa.getCollectionType()) {
                case COLLECTION:
                    return et.getCollection(fieldName).getElementType().getJavaType();
                case LIST:
                    return et.getList(fieldName).getElementType().getJavaType();
                case SET:
                    return et.getSet(fieldName).getElementType().getJavaType();
                case MAP:
                    throw new UnsupportedOperationException("Entity Map mapping unsupported for entity: " + et.getName() + " field name: " + fieldName);
            }
        }
    }
    throw new IllegalArgumentException("Field " + fieldName + " of entity " + et.getName() + " is not a plural attribute");
}
项目:elrest-java    文件JPAFilterImpltest.java   
@Test
public void hibernatePluralPathtest() {
    CriteriaBuilder build = em.getCriteriaBuilder();
    CriteriaQuery<OnetoManyInstance> critQ = build.createquery(OnetoManyInstance.class);
    Root<OnetoManyInstance> resultRoot = critQ.from(OnetoManyInstance.class);
    Path pluralPath = resultRoot.get("many");
    Bindable shouldBePluralAttribute = pluralPath.getModel();
    assertNotNull(shouldBePluralAttribute);

    assertTrue(shouldBePluralAttribute instanceof PluralAttribute);
}
项目:oma-riista-web    文件JpaSubQuery.java   
@Nonnull
public static <P,S> JpaSubQuery<P,S> of(@Nonnull final PluralAttribute<P,S> attribute) {
    return new AbstractSubQuery<P,S,PluralAttribute<P,S>>(Objects.requireNonNull(attribute)) {
        @Override
        protected From<P,S> join(final Root<P> root) {
            return CriteriaUtils.join(root,attribute);
        }
    };
}
项目:oma-riista-web    文件JpaSubQuery.java   
@Nonnull
public static <P,S> inverSEOf(@Nonnull final PluralAttribute<S,P> attribute) {
    return new AbstractReverseSubQuery<P,PluralAttribute<S,P>>(Objects.requireNonNull(attribute)) {
        @Override
        protected Path<P> getPathToParentRoot(final Root<S> root) {
            return CriteriaUtils.join(root,attribute);
        }
    };
}
项目:oma-riista-web    文件CriteriaUtils.java   
public static <T,U> boolean isCollectionLoaded(
        @Nonnull final T entity,? extends Collection<U>,U> pluralAttribute) {

    Objects.requireNonNull(entity,"entity is null");

    return getCollectionIfInitialized(pluralAttribute).apply(entity) != null;
}
项目:oma-riista-web    文件CriteriaUtils.java   
private static <T,C> getCollectionIfInitialized(
        final PluralAttribute<? super T,U> attribute) {

    Objects.requireNonNull(attribute);

    return new Function<T,C>() {

        // Cache for lazy-initialized function,not strictly thread-safe
        private Function<T,C> collectionFn;

        @Nullable
        @Override
        public C apply(@Nullable final T entity) {
            if (entity == null || !Hibernate.isInitialized(entity)) {
                return null;
            }

            if (collectionFn == null) {
                collectionFn = jpaCollection(attribute);
            }

            final C collection = collectionFn.apply(entity);

            return Hibernate.isInitialized(collection) ? collection : null;
        }
    };
}
项目:oma-riista-web    文件JpaSpecs.java   
@Nonnull
public static <T,X,Y> Specification<T> equal(
        @Nonnull final PluralAttribute<? super T,X> attribute1,@Nonnull final Singularattribute<? super X,Y> attribute2,@Nullable final Y value) {

    Objects.requireNonNull(attribute1,"attribute1 must not be null");
    Objects.requireNonNull(attribute2,"attribute2 must not be null");

    return (root,query,cb) -> JpaPreds.equal(cb,CriteriaUtils.join(root,attribute1).get(attribute2),value);
}
项目:jpasecurity    文件TypeDeFinition.java   
@Override
protected ManagedType<?> transform(TypeDeFinition typeDeFinition) {
    if (!path.hasSubpath()) {
        return forModel(metamodel).filter(typeDeFinition.getType());
    }
    Attribute<?,?>)filter.transform(typeDeFinition);
    if (attribute.isCollection()) {
        return (ManagedType<?>)((PluralAttribute<?,?>)attribute).getElementType();
    } else {
        return (ManagedType<?>)((Singularattribute<?,?>)attribute).getType();
    }
}
项目:kc-rice    文件JpaMetadataProviderImpl.java   
/**
    * Gets a collection's Metadata from the property descriptor.
    *
    * @param collections The list of plural attributes to process.
    * @return The list of collections for this data object.
    */
protected List<DataObjectCollection> getCollectionsFromMetadata(Set<PluralAttribute> collections) {
    List<DataObjectCollection> colls = new ArrayList<DataObjectCollection>(collections.size());
    for (PluralAttribute cd : collections) {
        colls.add(getCollectionMetadataFromCollectionAttribute(cd));
    }
    return colls;
}
项目:random-jpa    文件AttributeHelper.java   
public static Class<?> getAttributeClass(final Attribute<?,?> attribute) {
    if (attribute == null) {
        throw new NullPointerException(ATTRIBUTE_CANNOT_BE_NULL);
    }
    if (attribute instanceof PluralAttribute) {
        return ((PluralAttribute) attribute).getBindableJavaType();
    }
    return attribute.getJavaType();
}
项目:hibernate-semantic-query    文件AbstractFromImpl.java   
@Override
@SuppressWarnings({"unchecked"})
public <X,Y> JpaAttributeJoin<X,Y> join(String attributeName,JoinType jt) {
    if ( !canBeJoinSource() ) {
        throw illegalJoin();
    }

    if ( jt.equals( JoinType.RIGHT ) ) {
        throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
    }

    final Attribute<X,?> attribute = (Attribute<X,?>) locateAttribute( attributeName );
    if ( attribute.isCollection() ) {
        final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
        if ( PluralAttribute.CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
            return (JpaAttributeJoin<X,Y>) join( (CollectionAttribute) attribute,jt );
        }
        else if ( PluralAttribute.CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
            return (JpaAttributeJoin<X,Y>) join( (ListAttribute) attribute,jt );
        }
        else if ( PluralAttribute.CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
            return (JpaAttributeJoin<X,Y>) join( (SetAttribute) attribute,jt );
        }
        else {
            return (JpaAttributeJoin<X,Y>) join( (MapAttribute) attribute,jt );
        }
    }
    else {
        return (JpaAttributeJoin<X,Y>) join( (Singularattribute) attribute,jt );
    }
}
项目:hibernate-semantic-query    文件AbstractFromImpl.java   
@Override
@SuppressWarnings({"unchecked"})
public <X,Y> JpaCollectionJoin<X,Y> joinCollection(String attributeName,JoinType jt) {
    final Attribute<X,?>) locateAttribute( attributeName );
    if ( !attribute.isCollection() ) {
        throw new IllegalArgumentException( "Requested attribute was not a collection" );
    }

    final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
    if ( !PluralAttribute.CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
        throw new IllegalArgumentException( "Requested attribute was not a collection" );
    }

    return (JpaCollectionJoin<X,jt );
}
项目:hibernate-semantic-query    文件AbstractFromImpl.java   
@Override
@SuppressWarnings({"unchecked"})
public <X,Y> JpaSetJoin<X,Y> joinSet(String attributeName,?>) locateAttribute( attributeName );
    if ( !attribute.isCollection() ) {
        throw new IllegalArgumentException( "Requested attribute was not a set" );
    }

    final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
    if ( !PluralAttribute.CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
        throw new IllegalArgumentException( "Requested attribute was not a set" );
    }

    return (JpaSetJoin<X,Y> JpaListJoin<X,Y> joinList(String attributeName,?>) locateAttribute( attributeName );
    if ( !attribute.isCollection() ) {
        throw new IllegalArgumentException( "Requested attribute was not a list" );
    }

    final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
    if ( !PluralAttribute.CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
        throw new IllegalArgumentException( "Requested attribute was not a list" );
    }

    return (JpaListJoin<X,K,V> JpaMapJoin<X,V> joinMap(String attributeName,?>) locateAttribute( attributeName );
    if ( !attribute.isCollection() ) {
        throw new IllegalArgumentException( "Requested attribute was not a map" );
    }

    final PluralAttribute pluralAttribute = (PluralAttribute) attribute;
    if ( !PluralAttribute.CollectionType.MAP.equals( pluralAttribute.getCollectionType() ) ) {
        throw new IllegalArgumentException( "Requested attribute was not a map" );
    }

    return (JpaMapJoin<X,V>) join( (MapAttribute) attribute,Y> JpaFetch<X,Y> fetch(String attributeName,JoinType jt) {
    if ( !canBeFetchSource() ) {
        throw illegalFetch();
    }

    Attribute<X,?>) locateAttribute( attributeName );
    if ( attribute.isCollection() ) {
        return (JpaFetch<X,Y>) fetch( (PluralAttribute) attribute,jt );
    }
    else {
        return (JpaFetch<X,Y>) fetch( (Singularattribute) attribute,jt );
    }
}
项目:graphql-jpa    文件JpaDataFetcher.java   
private Predicate getPredicate(CriteriaBuilder cb,Root root,DataFetchingEnvironment environment,Argument argument) {
    Path path = null;
    if (!argument.getName().contains(".")) {
        Attribute argumentEntityAttribute = getAttribute(environment,argument);

        // If the argument is a list,let's assume we need to join and do an 'in' clause
        if (argumentEntityAttribute instanceof PluralAttribute) {
            Join join = root.join(argument.getName());
            return join.in(convertValue(environment,argument,argument.getValue()));
        }

        path = root.get(argument.getName());

        return cb.equal(path,convertValue(environment,argument.getValue()));
    } else {
        List<String> parts = Arrays.asList(argument.getName().split("\\."));
        for (String part : parts) {
            if (path == null) {
                path = root.get(part);
            } else {
                path = path.get(part);
            }
        }

        return cb.equal(path,argument.getValue()));
    }
}
项目:graphql-jpa    文件JpaDataFetcher.java   
private Class getJavaType(DataFetchingEnvironment environment,Argument argument) {
    Attribute argumentEntityAttribute = getAttribute(environment,argument);

    if (argumentEntityAttribute instanceof PluralAttribute)
        return ((PluralAttribute) argumentEntityAttribute).getElementType().getJavaType();

    return argumentEntityAttribute.getJavaType();
}
项目:teiid    文件JPAMetadataProcessor.java   
private void addForeignKeys(MetadataFactory mf,metamodel model,ManagedType<?> entity,Table entityTable) throws TranslatorException {
    for (Attribute<?,?> attr:entity.getAttributes()) {
        if (attr.isCollection()) {

            PluralAttribute pa = (PluralAttribute)attr;
            Table forignTable = null;

            for (EntityType et:model.getEntities()) {
                if (et.getJavaType().equals(pa.getElementType().getJavaType())) {
                    forignTable = mf.getSchema().getTable(et.getName());
                    break;
                }
            }

            if (forignTable == null) {
                continue;
            }

            // add foreign keys as columns in table first; check if they exist first
            ArrayList<String> keys = new ArrayList<String>();
            KeyRecord pk = entityTable.getPrimaryKey();
            for (Column entityColumn:pk.getColumns()) {
                addColumn(mf,entityColumn.getName(),entityColumn.getDatatype().getRuntimeTypeName(),forignTable);
                keys.add(entityColumn.getName());
            }

            if (!foreignKeyExists(keys,forignTable)) {
                addForiegnKey(mf,attr.getName(),keys,entityTable.getName(),forignTable);
            }
        }
    }
}
项目:javaee-lab    文件metamodelUtil.java   
/**
 * Retrieves cascade from metamodel attribute
 *
 * @param attribute given pluaral attribute
 * @return an empty collection if no jpa relation annotation can be found.
 */
public Collection<CascadeType> getCascades(PluralAttribute<?,?> attribute) {
    if (attribute.getJavaMember() instanceof AccessibleObject) {
        AccessibleObject accessibleObject = (AccessibleObject) attribute.getJavaMember();
        OnetoMany onetoMany = accessibleObject.getAnnotation(OnetoMany.class);
        if (onetoMany != null) {
            return newArrayList(onetoMany.cascade());
        }
        ManyToMany manyToMany = accessibleObject.getAnnotation(ManyToMany.class);
        if (manyToMany != null) {
            return newArrayList(manyToMany.cascade());
        }
    }
    return newArrayList();
}
项目:javaee-lab    文件metamodelUtil.java   
public boolean isOrphanRemoval(PluralAttribute<?,?> attribute) {
    if (attribute.getJavaMember() instanceof AccessibleObject) {
        AccessibleObject accessibleObject = (AccessibleObject) attribute.getJavaMember();
        OnetoMany onetoMany = accessibleObject.getAnnotation(OnetoMany.class);
        if (onetoMany != null) {
            return onetoMany.orphanRemoval();
        }
    }
    return true;
}
项目:jpasearch    文件metamodelUtil.java   
/**
 * Retrieves cascade from metamodel attribute
 * 
 * @return an empty collection if no jpa relation annotation can be found.
 */
public Collection<CascadeType> getCascades(PluralAttribute<?,?> attribute) {
    if (attribute.getJavaMember() instanceof AccessibleObject) {
        AccessibleObject accessibleObject = (AccessibleObject) attribute.getJavaMember();
        OnetoMany onetoMany = accessibleObject.getAnnotation(OnetoMany.class);
        if (onetoMany != null) {
            return Arrays.asList(onetoMany.cascade());
        }
        ManyToMany manyToMany = accessibleObject.getAnnotation(ManyToMany.class);
        if (manyToMany != null) {
            return Arrays.asList(manyToMany.cascade());
        }
    }
    return new ArrayList<>();
}
项目:jpasearch    文件metamodelUtil.java   
public boolean isOrphanRemoval(PluralAttribute<?,?> attribute) {
    if (attribute.getJavaMember() instanceof AccessibleObject) {
        AccessibleObject accessibleObject = (AccessibleObject) attribute.getJavaMember();
        OnetoMany onetoMany = accessibleObject.getAnnotation(OnetoMany.class);
        if (onetoMany != null) {
            return onetoMany.orphanRemoval();
        }
    }
    return true;
}
项目:rice    文件JpaMetadataProviderImpl.java   
/**
    * Gets a collection's Metadata from the property descriptor.
    *
    * @param collections The list of plural attributes to process.
    * @return The list of collections for this data object.
    */
protected List<DataObjectCollection> getCollectionsFromMetadata(Set<PluralAttribute> collections) {
    List<DataObjectCollection> colls = new ArrayList<DataObjectCollection>(collections.size());
    for (PluralAttribute cd : collections) {
        colls.add(getCollectionMetadataFromCollectionAttribute(cd));
    }
    return colls;
}

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