List of usage examples for javax.persistence.criteria JoinType INNER
JoinType INNER
To view the source code for javax.persistence.criteria JoinType INNER.
Click Source Link
From source file:ca.uhn.fhir.jpa.dao.SearchBuilder.java
private void createPredicateLastUpdatedForIndexedSearchParam(CriteriaBuilder builder, Root<? extends BaseResourceIndexedSearchParam> from, List<Predicate> predicates) { DateRangeParam lastUpdated = myParams.getLastUpdatedAndRemove(); if (lastUpdated != null) { From<BaseResourceIndexedSearchParam, ResourceTable> defJoin = from.join("myResource", JoinType.INNER); List<Predicate> lastUpdatedPredicates = createLastUpdatedPredicates(lastUpdated, builder, defJoin); predicates.addAll(lastUpdatedPredicates); }// w ww .java 2s .co m }
From source file:ca.uhn.fhir.jpa.dao.SearchBuilder.java
private void createPredicateLastUpdatedForResourceLink(CriteriaBuilder builder, Root<ResourceLink> from, List<Predicate> predicates) { DateRangeParam lastUpdated = myParams.getLastUpdatedAndRemove(); if (lastUpdated != null) { From<BaseResourceIndexedSearchParam, ResourceTable> defJoin = from.join("mySourceResource", JoinType.INNER); List<Predicate> lastUpdatedPredicates = createLastUpdatedPredicates(lastUpdated, builder, defJoin); predicates.addAll(lastUpdatedPredicates); }// w w w . j a v a 2 s .co m }
From source file:ca.uhn.fhir.jpa.dao.SearchBuilder.java
private void createSort(CriteriaBuilder theBuilder, Root<ResourceTable> theFrom, SortSpec theSort, List<Order> theOrders, List<Predicate> thePredicates) { if (theSort == null || isBlank(theSort.getParamName())) { return;//from w w w. j av a 2 s .c om } if (BaseResource.SP_RES_ID.equals(theSort.getParamName())) { From<?, ?> forcedIdJoin = theFrom.join("myForcedId", JoinType.LEFT); if (theSort.getOrder() == null || theSort.getOrder() == SortOrderEnum.ASC) { theOrders.add(theBuilder.asc(forcedIdJoin.get("myForcedId"))); theOrders.add(theBuilder.asc(theFrom.get("myId"))); } else { theOrders.add(theBuilder.desc(forcedIdJoin.get("myForcedId"))); theOrders.add(theBuilder.desc(theFrom.get("myId"))); } createSort(theBuilder, theFrom, theSort.getChain(), theOrders, thePredicates); return; } if (Constants.PARAM_LASTUPDATED.equals(theSort.getParamName())) { if (theSort.getOrder() == null || theSort.getOrder() == SortOrderEnum.ASC) { theOrders.add(theBuilder.asc(theFrom.get("myUpdated"))); } else { theOrders.add(theBuilder.desc(theFrom.get("myUpdated"))); } createSort(theBuilder, theFrom, theSort.getChain(), theOrders, thePredicates); return; } RuntimeSearchParam param = getSearchParam(theSort.getParamName()); if (param == null) { throw new InvalidRequestException("Unknown sort parameter '" + theSort.getParamName() + "'"); } String joinAttrName; String[] sortAttrName; switch (param.getParamType()) { case STRING: joinAttrName = "myParamsString"; sortAttrName = new String[] { "myValueExact" }; break; case DATE: joinAttrName = "myParamsDate"; sortAttrName = new String[] { "myValueLow" }; break; case REFERENCE: joinAttrName = "myResourceLinks"; sortAttrName = new String[] { "myTargetResourcePid" }; break; case TOKEN: joinAttrName = "myParamsToken"; sortAttrName = new String[] { "mySystem", "myValue" }; break; case NUMBER: joinAttrName = "myParamsNumber"; sortAttrName = new String[] { "myValue" }; break; case URI: joinAttrName = "myParamsUri"; sortAttrName = new String[] { "myUri" }; break; case QUANTITY: joinAttrName = "myParamsQuantity"; sortAttrName = new String[] { "myValue" }; break; default: throw new InvalidRequestException("This server does not support _sort specifications of type " + param.getParamType() + " - Can't serve _sort=" + theSort.getParamName()); } From<?, ?> stringJoin = theFrom.join(joinAttrName, JoinType.INNER); if (param.getParamType() == RestSearchParameterTypeEnum.REFERENCE) { thePredicates.add(stringJoin.get("mySourcePath").as(String.class).in(param.getPathsSplit())); } else { thePredicates.add(theBuilder.equal(stringJoin.get("myParamName"), theSort.getParamName())); } // Predicate p = theBuilder.equal(stringJoin.get("myParamName"), theSort.getParamName()); // Predicate pn = theBuilder.isNull(stringJoin.get("myParamName")); // thePredicates.add(theBuilder.or(p, pn)); for (String next : sortAttrName) { if (theSort.getOrder() == null || theSort.getOrder() == SortOrderEnum.ASC) { theOrders.add(theBuilder.asc(stringJoin.get(next))); } else { theOrders.add(theBuilder.desc(stringJoin.get(next))); } } createSort(theBuilder, theFrom, theSort.getChain(), theOrders, thePredicates); }
From source file:org.batoo.jpa.core.impl.criteria.join.AbstractFrom.java
/** * {@inheritDoc}/* ww w. j ava 2 s . co m*/ * */ @Override public <Y> CollectionJoinImpl<X, Y> join(CollectionAttribute<? super X, Y> collection) { return this.join(collection, JoinType.INNER); }
From source file:org.batoo.jpa.core.impl.criteria.join.AbstractFrom.java
/** * {@inheritDoc}/*w w w . j av a 2 s . com*/ * */ @Override public <Y> ListJoinImpl<X, Y> join(ListAttribute<? super X, Y> list) { return this.join(list, JoinType.INNER); }
From source file:org.batoo.jpa.core.impl.criteria.join.AbstractFrom.java
/** * {@inheritDoc}/* ww w .j a v a 2 s.c o m*/ * */ @Override public <K, V> MapJoinImpl<X, K, V> join(MapAttribute<? super X, K, V> map) { return this.join(map, JoinType.INNER); }
From source file:org.batoo.jpa.core.impl.criteria.join.AbstractFrom.java
/** * {@inheritDoc}/*from w ww .ja va 2 s.co m*/ * */ @Override public <Y> SetJoinImpl<X, Y> join(SetAttribute<? super X, Y> set) { return this.join(set, JoinType.INNER); }
From source file:org.batoo.jpa.core.impl.criteria.join.AbstractFrom.java
/** * {@inheritDoc}// www . j ava 2 s . c om * */ @Override public <Y> AbstractJoin<X, Y> join(SingularAttribute<? super X, Y> attribute) { return this.join(attribute, JoinType.INNER); }
From source file:org.batoo.jpa.core.impl.criteria.join.AbstractFrom.java
/** * {@inheritDoc}/* ww w .jav a 2 s . c o m*/ * */ @Override public <Y> AbstractJoin<X, Y> join(String attributeName) { return this.join(attributeName, JoinType.INNER); }
From source file:org.batoo.jpa.core.impl.criteria.join.AbstractFrom.java
/** * {@inheritDoc}/* w w w.ja va 2s . c o m*/ * */ @Override public <Y> CollectionJoinImpl<X, Y> joinCollection(String attributeName) { return this.joinCollection(attributeName, JoinType.INNER); }