当前位置: 首页>>代码示例>>Java>>正文


Java Bindable类代码示例

本文整理汇总了Java中javax.persistence.metamodel.Bindable的典型用法代码示例。如果您正苦于以下问题:Java Bindable类的具体用法?Java Bindable怎么用?Java Bindable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Bindable类属于javax.persistence.metamodel包,在下文中一共展示了Bindable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: containsRelation

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
public static boolean containsRelation(Object expr) {
	if (expr instanceof Join) {
		return true;
	} else if (expr instanceof SingularAttribute) {
		SingularAttribute<?, ?> attr = (SingularAttribute<?, ?>) expr;
		return attr.isAssociation();
	} else if (expr instanceof Path) {
		Path<?> attrPath = (Path<?>) expr;
		Bindable<?> model = attrPath.getModel();
		Path<?> parent = attrPath.getParentPath();
		return containsRelation(parent) || containsRelation(model);
	} else {
		// we may can do better here...
		return false;
	}
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:17,代码来源:QueryUtil.java

示例2: toType

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
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 );
		}
	}
}
 
开发者ID:hibernate,项目名称:hibernate-semantic-query,代码行数:17,代码来源:Helper.java

示例3: getPath

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
@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 ((attributes.indexOf(attribute) != (attributes.size() - 1)) && (attribute instanceof Bindable)
                    && Identifiable.class.isAssignableFrom(((Bindable<?>) attribute).getBindableJavaType()) && (path instanceof From)) {
                path = ((From<?, ?>) path).join(attribute.getName(), JoinType.LEFT);
            } else {
                path = path.get(attribute.getName());
            }
        }
    }
    return (Path<F>) path;
}
 
开发者ID:jpasearch,项目名称:jpasearch,代码行数:26,代码来源:JpaUtil.java

示例4: hibernatePluralPathTest

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
@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);
}
 
开发者ID:gdjennings,项目名称:elrest-java,代码行数:12,代码来源:JPAFilterImplTest.java

示例5: containsRelation

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
public static boolean containsRelation(Object expr) {
  if (expr instanceof Join) {
    return true;
  }
  else if (expr instanceof SingularAttribute) {
    SingularAttribute<?, ?> attr = (SingularAttribute<?, ?>) expr;
    return attr.isAssociation();
  }
  else if (expr instanceof Path) {
    Path<?> attrPath = (Path<?>) expr;
    Bindable<?> model = attrPath.getModel();
    Path<?> parent = attrPath.getParentPath();
    return containsRelation(parent) || containsRelation(model);
  }
  else {
    // we may can do better here...
    return false;
  }
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:20,代码来源:QueryUtil.java

示例6: getName

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
private String getName(Bindable<?> bindable) {
    if (bindable.getBindableType() == BindableType.ENTITY_TYPE) {
        EntityType<?> entityType = (EntityType<?>)bindable;
        return entityType.getName();
    } else {
        Attribute<?, ?> attribute = (Attribute<?, ?>)bindable;
        return attribute.getName();
    }
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:10,代码来源:CriteriaEntityFilter.java

示例7: getEntityType

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
/**
 * Get the Breeze name of the entity type. For collections, Breeze expects the name of the
 * element type.
 * 
 * @param propType
 * @return
 */
Class getEntityType(Attribute attr) {
    if (attr instanceof Bindable) {
        return ((Bindable)attr).getBindableJavaType();
    } else {
        throw new RuntimeException("Not Bindable: " + attr);
    }
}
 
开发者ID:Breeze,项目名称:breeze.server.java,代码行数:15,代码来源:JPAMetadata.java

示例8: isDistinctable

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
static boolean isDistinctable(MetaJpaConstructor<?, ?, ?> projection, int columnIndex) {
    logger.debug("isDistinctable({},{})", projection, columnIndex);
    boolean ret = Bindable.class.isAssignableFrom(projection.getConstructorParameterTypes().get(columnIndex)) &&
                  !NotDistinctable.class.isAssignableFrom(((Bindable<?>)projection.getParameters().get(columnIndex)).getBindableJavaType()) ||
                  !Bindable.class.isAssignableFrom(projection.getConstructorParameterTypes().get(columnIndex)) &&
                  NotDistinctable.class.isAssignableFrom(projection.getParameters().get(columnIndex).getJavaType());
    logger.debug("isDistinctable -> {}", ret);
    return ret;
}
 
开发者ID:solita,项目名称:query-utils,代码行数:10,代码来源:ProjectionUtil.java

示例9: collectEmbeddableFromParts

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
static Object collectEmbeddableFromParts(Metamodel metamodel, Bindable<?> attr, Iterable<Object> columns) {
    logger.debug("collectEmbeddableFromParts({},{},{})", new Object[] {metamodel, attr, columns});
    List<Object> cols = newList(columns);
    List<? extends Attribute<?, ?>> embeddableAttributes = getEmbeddableAttributes(attr, metamodel);
    if (embeddableAttributes.size() != cols.size()) {
        throw new IllegalStateException("Expected same size for: " + embeddableAttributes + ", " + cols);
    }
    Class<?> embeddableClass = getEmbeddableType(attr, metamodel).getJavaType();
    try {
        Object ret = instantiate(embeddableClass);
        for (Tuple2<? extends Attribute<?, ?>, Object> a: zip(embeddableAttributes, cols)) {
            Member member = a._1.getJavaMember();
            if (member instanceof Field) {
                Field f = (Field)member;
                f.setAccessible(true);
                f.set(ret, a._2);
            } else {
                Method m = (Method)member;
                if (m.getParameterTypes().length == 1 && head(m.getParameterTypes()).isAssignableFrom(a._1.getJavaType())) {
                    m.setAccessible(true);
                    m.invoke(ret, a._2);
                } else {
                    throw new UnsupportedOperationException("not implemented. Run, Forrest, run!");
                }
            }
        }
        logger.debug("collectEmbeddableFromParts -> {}", ret);
        return ret;
    } catch (Exception e)  {
        throw new RuntimeException(e);
    }
}
 
开发者ID:solita,项目名称:query-utils,代码行数:33,代码来源:EmbeddableUtil.java

示例10: optionalSubtype

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
public static <E, T> SingularAttribute<E, Option<T>> optionalSubtype(SingularAttribute<? extends E, T> attribute) throws IllegalArgumentException {
    if (attribute instanceof PseudoAttribute) {
        throw new IllegalArgumentException("No reason to wrap a PseudoAttribute. Right?");
    }
    if (attribute instanceof Bindable && Option.class.isAssignableFrom(((Bindable<?>) attribute).getBindableJavaType())) {
        throw new IllegalArgumentException("No reason to wrap an Option<?> type. Right?");
    }
    if (attribute instanceof AdditionalQueryPerformingAttribute) {
        List<Attribute<?,?>> parameters = ((AdditionalQueryPerformingAttribute) attribute).getConstructor().getParameters();
        if (parameters.size() == 1 && Option.class.isAssignableFrom(head(parameters).getJavaType())) {
            throw new IllegalArgumentException("No reason to wrap an Option<?> type. Right?");
        }
    }
    return OptionalAttribute.Constructors.optional(attribute);
}
 
开发者ID:solita,项目名称:query-utils,代码行数:16,代码来源:Cast.java

示例11: isRequiredByQueryAttribute

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
public static boolean isRequiredByQueryAttribute(Attribute<?,?> param) {
    if (param == null) {
        return true;
    }
    if (unwrap(PseudoAttribute.class, param).isDefined()) {
        return true;
    }
    
    if (param instanceof AdditionalQueryPerformingAttribute && ((AdditionalQueryPerformingAttribute) param).getConstructor() instanceof TransparentProjection) {
        return isRequiredByQueryAttribute(((TransparentProjection)((AdditionalQueryPerformingAttribute) param).getConstructor()).getWrapped());
    }
    
    if (param instanceof JoiningAttribute && param instanceof SingularAttribute) {
        return forall(QueryUtils_.isRequiredByQueryAttribute, ((JoiningAttribute) param).getAttributes());
    } else if (param instanceof JoiningAttribute) {
        return true;
    }
    
    if (unwrap(OptionalAttribute.class, param).isDefined()) {
        return false;
    }
    
    if (param instanceof Bindable && Option.class.isAssignableFrom(((Bindable<?>) param).getBindableJavaType())) {
        return false;
    }
    
    return true;
}
 
开发者ID:solita,项目名称:query-utils,代码行数:29,代码来源:QueryUtils.java

示例12: resolveSelection

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
/**
 * Modifies existing query!
 */
public <E, T1, A1 extends Attribute<? super E, ?> & Bindable<T1>> CriteriaQuery<E>
innerJoin(A1 attribute, CriteriaQuery<E> query) {
    @SuppressWarnings("unchecked")
    From<?, E> from = (From<?, E>) resolveSelection(query);
    join(from, attribute, JoinType.INNER);
    return query;
}
 
开发者ID:solita,项目名称:query-utils,代码行数:11,代码来源:Restrict.java

示例13: getModel

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
@Override
public Bindable<X> getModel() {
	// TODO Auto-generated method stub
	return null;
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:6,代码来源:MugglPath.java

示例14: getModel

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
@Override
public Bindable<X> getModel()
{
	// TODO Auto-generated method stub
	return null;
}
 
开发者ID:ltearno,项目名称:hexa.tools,代码行数:7,代码来源:PathImpl.java

示例15: set

import javax.persistence.metamodel.Bindable; //导入依赖的package包/类
public static <E,Y,Y2,Y3,Y4,Y5,A1 extends Attribute<E,?> & Bindable<Y>, A2 extends Attribute<? super Y,?> & Bindable<Y2>, A3 extends Attribute<? super Y2,?> & Bindable<Y3>, A4 extends Attribute<? super Y3,?> & Bindable<Y4>, A5 extends Attribute<? super Y4,?> & Bindable<Y5>>
SetAttribute<E,Y5> set(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
    return new JoiningSetAttribute<E,Y5,SetAttribute<E,Y5>>(newList((Attribute<?,?>)a1, (Attribute<?,?>)a2, (Attribute<?,?>)a3, (Attribute<?,?>)a4, (Attribute<?,?>)a5));
}
 
开发者ID:solita,项目名称:query-utils,代码行数:5,代码来源:JoiningAttribute.java


注:本文中的javax.persistence.metamodel.Bindable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。