Class JPAExpandJoinQuery
java.lang.Object
com.sap.olingo.jpa.processor.core.query.JPAAbstractQuery
com.sap.olingo.jpa.processor.core.query.JPAAbstractJoinQuery
com.sap.olingo.jpa.processor.core.query.JPAExpandJoinQuery
- All Implemented Interfaces:
JPAQuery
A query to retrieve the expand entities.
According to OData Version 4.0 Part 2 - 5.1.2 System Query Option $expand the following query options are allowed:
- expandCountOption = filter/ search
- expandRefOption = expandCountOption/ orderby / skip / top / inlinecount
- expandOption = expandRefOption/ select/ expand / levels
- Author:
- Oliver Grande
-
Field Summary
Fields inherited from class com.sap.olingo.jpa.processor.core.query.JPAAbstractJoinQuery
ALIAS_SEPERATOR, context, cq, lastInfo, navigationInfo, page, requestContext, root, target, uriResourceFields inherited from class com.sap.olingo.jpa.processor.core.query.JPAAbstractQuery
cb, claimsProvider, debugger, em, groups, jpaEntity, locale, odata, sd, SELECT_ALL, SELECT_ITEM_SEPERATOR -
Constructor Summary
ConstructorsConstructorDescriptionJPAExpandJoinQuery(org.apache.olingo.server.api.OData odata, JPAODataCRUDContextAccess context, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath assoziation, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType entityType, Map<String,List<String>> requestHeaders, JPAODataRequestContextAccess requestContext)JPAExpandJoinQuery(org.apache.olingo.server.api.OData odata, JPAODataCRUDContextAccess sessionContext, JPAInlineItemInfo item, Map<String,List<String>> requestHeaders, JPAODataRequestContextAccess requestContext, Optional<JPAKeyBoundary> keyBoundary) -
Method Summary
Modifier and TypeMethodDescriptionprotected Set<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath>buildSelectionPathList(org.apache.olingo.server.api.uri.UriInfoResource uriResource)Creates the path to all properties that need to be selected from the database.protected List<javax.persistence.criteria.Selection<?>>createSelectClause(Map<String,javax.persistence.criteria.From<?,?>> joinTables, Collection<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath> jpaPathList, javax.persistence.criteria.From<?,?> target, List<String> groups)The value of the $select query option is a comma-separated list of properties, qualified action names, qualified function names, the star operator (*), or the star operator prefixed with the namespace or alias of the schema in order to specify all operations defined in the schema.execute()Process a expand query, which may contains a $skip and/or a $top option.Methods inherited from class com.sap.olingo.jpa.processor.core.query.JPAAbstractJoinQuery
addTopSkip, buildEntityPathList, buildSelectionAddNavigationAndSelect, createBoundary, createFromClause, createKeyWhere, createProtectionWhere, createWhere, determineAssoziation, determineLastInfo, determineTargetIsCollection, expandPath, extractDescriptionAttributes, generateCollectionAttributeJoin, getLocale, getQuery, getRootMethods inherited from class com.sap.olingo.jpa.processor.core.query.JPAAbstractQuery
addWhereClause, createJoinFromPath, createProtectionWhereForEntityType, createWhereByKey, generateDesciptionJoin, getDebugger, orWhereClause
-
Constructor Details
-
JPAExpandJoinQuery
public JPAExpandJoinQuery(org.apache.olingo.server.api.OData odata, JPAODataCRUDContextAccess sessionContext, JPAInlineItemInfo item, Map<String,List<String>> requestHeaders, JPAODataRequestContextAccess requestContext, Optional<JPAKeyBoundary> keyBoundary) throws org.apache.olingo.commons.api.ex.ODataException- Throws:
org.apache.olingo.commons.api.ex.ODataException
-
JPAExpandJoinQuery
public JPAExpandJoinQuery(org.apache.olingo.server.api.OData odata, JPAODataCRUDContextAccess context, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath assoziation, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType entityType, Map<String,List<String>> requestHeaders, JPAODataRequestContextAccess requestContext) throws org.apache.olingo.commons.api.ex.ODataException- Throws:
org.apache.olingo.commons.api.ex.ODataException
-
-
Method Details
-
execute
Process a expand query, which may contains a $skip and/or a $top option.This is a tricky problem, as it can not be done easily with SQL. It could be that a database offers special solutions. There is an worth reading blog regards this topic: How to select the first/least/max row per group in SQL. Often databases offer the option to use
ROW_NUMBERtogether withOVER ... ORDER BYsee e.g. SQL ROW_NUMBER. Unfortunately this is not supported by JPA.- Returns:
- query result
- Throws:
org.apache.olingo.server.api.ODataApplicationException
-
createSelectClause
protected List<javax.persistence.criteria.Selection<?>> createSelectClause(Map<String,javax.persistence.criteria.From<?,?>> joinTables, Collection<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath> jpaPathList, javax.persistence.criteria.From<?,?> target, List<String> groups) throws org.apache.olingo.server.api.ODataApplicationExceptionDescription copied from class:JPAAbstractJoinQueryThe value of the $select query option is a comma-separated list of properties, qualified action names, qualified function names, the star operator (*), or the star operator prefixed with the namespace or alias of the schema in order to specify all operations defined in the schema. See: OData Version 4.0 Part 1 - 11.2.4.1 System Query Option $selectSee also: OData Version 4.0 Part 2 - 5.1.3 System Query Option $select
- Overrides:
createSelectClausein classJPAAbstractJoinQuery- Returns:
- Throws:
org.apache.olingo.server.api.ODataApplicationException
-
buildSelectionPathList
protected Set<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath> buildSelectionPathList(org.apache.olingo.server.api.uri.UriInfoResource uriResource) throws org.apache.olingo.server.api.ODataApplicationExceptionDescription copied from class:JPAAbstractJoinQueryCreates the path to all properties that need to be selected from the database. A Property can be included for the following reasons:- It is a key in order to be able to build the links
- It is part of the $select system query option
- It is the result of a navigation, which my be restricted by a $select
- If is required to link $expand with result with the parent result
- A stream is requested and the property contains the mime type>
- Overrides:
buildSelectionPathListin classJPAAbstractJoinQuery- Returns:
- Throws:
org.apache.olingo.server.api.ODataApplicationException
-