本文整理汇总了Java中javax.persistence.criteria.From.join方法的典型用法代码示例。如果您正苦于以下问题:Java From.join方法的具体用法?Java From.join怎么用?Java From.join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.persistence.criteria.From
的用法示例。
在下文中一共展示了From.join方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: join
import javax.persistence.criteria.From; //导入方法依赖的package包/类
@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();
}
示例2: copyJoins
import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
* @return last possibly used alias
*/
private int copyJoins(From<?, ?> from, From<?, ?> to, int counter) {
for (Join<?, ?> join : sort(comparator, from.getJoins())) {
Attribute<?, ?> attr = join.getAttribute();
// Hibern fails with String-bases api; Join.join(String, JoinType)
@SuppressWarnings({ "rawtypes", "unchecked" })
Join<Object, Object> j = attr instanceof SingularAttribute ? to.join((SingularAttribute) join.getAttribute(), join.getJoinType()) :
attr instanceof CollectionAttribute ? to.join((CollectionAttribute) join.getAttribute(), join.getJoinType()) :
attr instanceof SetAttribute ? to.join((SetAttribute) join.getAttribute(), join.getJoinType()) :
attr instanceof ListAttribute ? to.join((ListAttribute) join.getAttribute(), join.getJoinType()) :
attr instanceof MapAttribute ? to.join((MapAttribute) join.getAttribute(), join.getJoinType()) :
to.join((CollectionAttribute) join.getAttribute(), join.getJoinType());
copyAlias(join, j, ++counter);
counter = copyJoins(join, j, ++counter);
}
copyFetches(from, to);
return counter;
}
示例3: getExpression
import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
* Cree une expression Criteria API avec l'atribut de l'entité passé en parametre
*
* @param root
* entité JPA contenant le champ
* @param columnData
* nom du champ
* @param clazz
* class du champ
* @param <S>
* type du champ
* @return l'expression de l'atribut
*/
public static <S> Path<S> getExpression(final Root<?> root, final String columnData, final Class<S> clazz) {
if (!columnData.contains(DatatableSpecification.ATTRIBUTE_SEPARATOR)) {
// columnData is like "attribute" so nothing particular to do
return root.get(columnData);
}
// columnData is like "joinedEntity.attribute" so add a join clause
final String[] values = columnData.split(DatatableSpecification.ESCAPED_ATTRIBUTE_SEPARATOR);
final Attribute<?, ?> attribute = root.getModel().getAttribute(values[0]);
if (attribute == null) {
throw new IllegalArgumentException(
"Colonne '" + values[0] + "' (" + columnData + ") introuvable depuis l'entité '" + root.getJavaType()
+ "'");
}
if (attribute.getPersistentAttributeType() == PersistentAttributeType.EMBEDDED) {
// with @Embedded attribute
return root.get(values[0]).get(values[1]);
}
From<?, ?> from = root;
for (int i = 0; i < values.length - 1; i++) {
Join<?, ?> join = null;
for (final Join<?, ?> joinCandidate : from.getJoins()) {
if (joinCandidate.getAttribute().getName().equals(values[i])) {
// LOGGER.debug("Trouve joint d'entite: '{}'", values[i]);
join = joinCandidate;
}
}
if (join == null) {
// LOGGER.debug("Joigant entite '{}'...", values[i]);
join = from.join(values[i], JoinType.INNER);
}
from = join;
}
return from.get(values[values.length - 1]);
}
示例4: copyJoins
import javax.persistence.criteria.From; //导入方法依赖的package包/类
private void copyJoins(From<?, ?> from, From<?, ?> to) {
for (Join<?, ?> join : from.getJoins()) {
Join<?, ?> toJoin = to.join(join.getAttribute().getName(), join.getJoinType());
toJoin.alias(getAlias(join));
copyJoins(join, toJoin);
}
for (Fetch<?, ?> fetch : from.getFetches()) {
Fetch<?, ?> toFetch = to.fetch(fetch.getAttribute().getName());
copyFetches(fetch, toFetch);
}
}
示例5: doJoin
import javax.persistence.criteria.From; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public From<?, ?> doJoin(MetaAttribute targetAttr, JoinType joinType, From<?, ?> parent) {
if (targetAttr instanceof MetaComputedAttribute) {
MetaComputedAttribute projAttr = (MetaComputedAttribute) targetAttr;
@SuppressWarnings("rawtypes")
JpaCriteriaExpressionFactory expressionFactory = (JpaCriteriaExpressionFactory<?>) queryImpl.getComputedAttrs()
.get(projAttr);
return (From<?, ?>) expressionFactory.getExpression(parent, getCriteriaQuery());
}
else {
return parent.join(targetAttr.getName(), joinType);
}
}
示例6: visit
import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public boolean visit(JpqlInnerJoin node, CriteriaHolder query) {
Path path = new Path(node.jjtGetChild(0).toString());
Alias alias = getAlias(node);
From<?, ?> from = query.getFrom(path.getRootAlias());
Join<Object, Object> join = from.join(path.getSubpath(), JoinType.INNER);
if (alias != null) {
join.alias(alias.getName());
}
return false;
}
示例7: getQueryRestriction
import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
* TODO This method may be bformat specific. Consider creating new abstract class to group all bformat related DAO. Builds a query restriction predicate for
* the specified business object format entity as per business object format key values.
*
* @param builder the criteria builder
* @param businessObjectFormatEntity the business object format entity that appears in the from clause
* @param fileTypeEntity the file type entity that appears in the from clause
* @param businessObjectDefinitionEntity the business object definition entity that appears in the from clause
* @param businessObjectFormatKey the business object format key
* @param ignoreBusinessObjectFormatVersion specifies whether to ignore the business object format version when building the predicate
*
* @return the query restriction predicate
*/
protected Predicate getQueryRestriction(CriteriaBuilder builder, From<?, BusinessObjectFormatEntity> businessObjectFormatEntity,
From<?, FileTypeEntity> fileTypeEntity, From<?, BusinessObjectDefinitionEntity> businessObjectDefinitionEntity,
BusinessObjectFormatKey businessObjectFormatKey, boolean ignoreBusinessObjectFormatVersion)
{
// Join to the other tables we can filter on.
Join<BusinessObjectDefinitionEntity, NamespaceEntity> namespaceEntity = businessObjectDefinitionEntity.join(BusinessObjectDefinitionEntity_.namespace);
// Create the standard restrictions based on the business object format key values (i.e. the standard where clauses).
// Create a restriction on namespace code.
Predicate predicate = builder.equal(builder.upper(namespaceEntity.get(NamespaceEntity_.code)), businessObjectFormatKey.getNamespace().toUpperCase());
// Create and append a restriction on business object definition name.
predicate = builder.and(predicate, builder.equal(builder.upper(businessObjectDefinitionEntity.get(BusinessObjectDefinitionEntity_.name)),
businessObjectFormatKey.getBusinessObjectDefinitionName().toUpperCase()));
// Create and append a restriction on business object format usage.
predicate = builder.and(predicate, builder.equal(builder.upper(businessObjectFormatEntity.get(BusinessObjectFormatEntity_.usage)),
businessObjectFormatKey.getBusinessObjectFormatUsage().toUpperCase()));
// Create and append a restriction on business object format file type.
predicate = builder.and(predicate,
builder.equal(builder.upper(fileTypeEntity.get(FileTypeEntity_.code)), businessObjectFormatKey.getBusinessObjectFormatFileType().toUpperCase()));
// If specified, create and append a restriction on business object format version.
if (!ignoreBusinessObjectFormatVersion && businessObjectFormatKey.getBusinessObjectFormatVersion() != null)
{
predicate = builder.and(predicate, builder.equal(businessObjectFormatEntity.get(BusinessObjectFormatEntity_.businessObjectFormatVersion),
businessObjectFormatKey.getBusinessObjectFormatVersion()));
}
return predicate;
}
示例8: getFieldPath
import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
* Resolves the Path for a field in the persistence layer and joins the
* required models. This operation is part of a tree traversal through
* an RSQL expression. It creates for every field that is not part of
* the root model a join to the foreign model. This behavior is
* optimized when several joins happen directly under an OR node in the
* traversed tree. The same foreign model is only joined once.
*
* Example: tags.name==M;(tags.name==A,tags.name==B,tags.name==C) This
* example joins the tags model only twice, because for the OR node in
* brackets only one join is used.
*
* @param enumField
* field from a FieldNameProvider to resolve on the
* persistence layer
* @param finalProperty
* dot notated field path
* @return the Path for a field
*/
private Path<Object> getFieldPath(final A enumField, final String finalProperty) {
Path<Object> fieldPath = null;
final String[] split = finalProperty.split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
for (int i = 0; i < split.length; i++) {
final boolean isMapKeyField = enumField.isMap() && i == (split.length - 1);
if (isMapKeyField) {
return fieldPath;
}
final String fieldNameSplit = split[i];
fieldPath = (fieldPath != null) ? fieldPath.get(fieldNameSplit) : root.get(fieldNameSplit);
if (fieldPath instanceof PluralJoin) {
final Join<Object, ?> join = (Join<Object, ?>) fieldPath;
final From<?, Object> joinParent = join.getParent();
final Optional<Join<Object, Object>> currentJoinOfType = findCurrentJoinOfType(join.getJavaType());
if (currentJoinOfType.isPresent() && isOrLevel) {
// remove the additional join and use the existing one
joinParent.getJoins().remove(join);
fieldPath = currentJoinOfType.get();
} else {
final Join<Object, Object> newJoin = joinParent.join(fieldNameSplit, JoinType.LEFT);
addCurrentJoin(newJoin);
fieldPath = newJoin;
}
}
}
return fieldPath;
}
示例9: getPath
import javax.persistence.criteria.From; //导入方法依赖的package包/类
protected <T, S> Path<?> getPath(From<T, S> root, String name) {
int index = name.indexOf(".");
if (index > 0 ) {
String attribute = name.substring(0, index);
From<S, ?> join = getJoin(attribute, root.getJoins());
if (join == null) {
join = root.join(attribute);
}
return getPath(join, name.substring(index + 1));
} else {
return root.get(name);
}
}
示例10: copyJoins
import javax.persistence.criteria.From; //导入方法依赖的package包/类
/**
* Copy Joins
* @param from source Join
* @param to destination Join
*/
public static void copyJoins(From<?, ?> from, From<?, ?> to) {
for (Join<?, ?> j : from.getJoins()) {
Join<?, ?> toJoin = to.join(j.getAttribute().getName(), j.getJoinType());
toJoin.alias(getOrCreateAlias(j));
copyJoins(j, toJoin);
}
}
示例11: joinSingular
import javax.persistence.criteria.From; //导入方法依赖的package包/类
private Join joinSingular(From path)
{
if (joinType == null)
{
return path.join(singular);
}
return path.join(singular, joinType);
}
示例12: joinList
import javax.persistence.criteria.From; //导入方法依赖的package包/类
private Join joinList(From path)
{
if (joinType == null)
{
return path.join(list);
}
return path.join(list, joinType);
}
示例13: joinCollection
import javax.persistence.criteria.From; //导入方法依赖的package包/类
private Join joinCollection(From path)
{
if (joinType == null)
{
return path.join(collection);
}
return path.join(collection, joinType);
}
示例14: joinSet
import javax.persistence.criteria.From; //导入方法依赖的package包/类
private Join joinSet(From path)
{
if (joinType == null)
{
return path.join(set);
}
return path.join(set, joinType);
}
示例15: joinMap
import javax.persistence.criteria.From; //导入方法依赖的package包/类
private Join joinMap(From path)
{
if (joinType == null)
{
return path.join(map);
}
return path.join(map, joinType);
}