Skip to content

Update release branch #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ clone the repository, import the projects and declare a dependency to either the
<dependency>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa-metadata</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</dependency>
```

Expand All @@ -57,7 +57,7 @@ Or to the complete processor:
<dependency>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa-processor</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</dependency>
```

Expand Down Expand Up @@ -101,3 +101,4 @@ Detailed information including third-party components and their licensing/copyri
|2.0.0| - Minimum Java release now 17<br>- Switch to Jakarta Persistence<br> - Support of Spring Boot 3.x<br> - JPAEdmMetadataPostProcessor became an interface |Yes|
|2.0.2| - Solution for issue [#239](https://github.com/SAP/olingo-jpa-processor-v4/issues/239)<br> - Partial solution for issue [#226](https://github.com/SAP/olingo-jpa-processor-v4/issues/226)<br> - Solution for issue [#238](https://github.com/SAP/olingo-jpa-processor-v4/issues/238) and [#236](https://github.com/SAP/olingo-jpa-processor-v4/issues/236)|No|
|2.1.0| - Enhancement of annotation API<br>- Enhancement of API for server driven paging<br>- Optional support of IN operand <br>- Update to Olingo 5.0.0<br>- Rework $count implementation<br>- Fix problem with $count on collection properties|No|
|2.1.1| - Fix for issue [#292] (https://github.com/SAP/olingo-jpa-processor-v4/issues/292)|No|
2 changes: 1 addition & 1 deletion jpa-archetype/odata-jpa-archetype-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa-archetype</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>odata-jpa-archetype-spring</artifactId>
<name>Archetype - odata-jpa-archetype-spring</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</parent>

<properties>
<processor.version>2.1.0</processor.version>
<processor.version>2.1.1</processor.version>
<java.version>17</java.version>
<build.sourceEncoding>UTF-8</build.sourceEncoding>
<eclipselink.version>4.0.2</eclipselink.version>
Expand Down
4 changes: 2 additions & 2 deletions jpa-archetype/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa-archetype</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
<packaging>pom</packaging>
<url>https://github.com/SAP/olingo-jpa-processor-v4</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.source>17</project.build.source>
<odata.jpa.version>2.1.0</odata.jpa.version>
<odata.jpa.version>2.1.1</odata.jpa.version>
</properties>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion jpa-tutorial/QuickStart/QuickStart.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This should contain the information about archetype:
<archetype>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa-archetype-spring</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</archetype>
</archetypes>
</archetype-catalog>
Expand Down
2 changes: 1 addition & 1 deletion jpa/odata-jpa-annotation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>odata-jpa-annotation</artifactId>
<name>odata-jpa-annotation</name>
Expand Down
2 changes: 1 addition & 1 deletion jpa/odata-jpa-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>

<artifactId>odata-jpa-coverage</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions jpa/odata-jpa-metadata/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.0</version>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.1</version>
</parent>

<artifactId>odata-jpa-metadata</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jpa/odata-jpa-odata-vocabularies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>odata-jpa-odata-vocabularies</artifactId>
<name>odata-jpa-odata-vocabularies</name>
Expand Down
2 changes: 1 addition & 1 deletion jpa/odata-jpa-processor-cb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>

<artifactId>odata-jpa-processor-cb</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jpa/odata-jpa-processor-ext/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>odata-jpa-processor-ext</artifactId>
<name>odata-jpa-processor-ext</name>
Expand Down
2 changes: 1 addition & 1 deletion jpa/odata-jpa-processor-parallel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>

<artifactId>odata-jpa-processor-parallel</artifactId>
Expand Down
6 changes: 6 additions & 0 deletions jpa/odata-jpa-processor/.project
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
Expand Down
2 changes: 1 addition & 1 deletion jpa/odata-jpa-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>

<artifactId>odata-jpa-processor</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private JPAQueryCreationResult createTupleQuery() throws ODataApplicationExcepti
final Map<String, From<?, ?>> joinTables = createFromClause(orderByAttributes, selectionPath.joinedPersistent(),
cq, lastInfo);
// TODO handle Join Column is ignored
cq.multiselect(createSelectClause(joinTables, selectionPath.joinedPersistent(), target, groups));
cq.multiselect(createSelectClause(joinTables, selectionPath.joinedPersistent(), target, groups)).distinct(true);
final jakarta.persistence.criteria.Expression<Boolean> whereClause = createWhere();
if (whereClause != null)
cq.where(whereClause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import com.sap.olingo.jpa.processor.core.api.JPAServiceDebugger;
import com.sap.olingo.jpa.processor.core.database.JPADefaultDatabaseProcessor;
import com.sap.olingo.jpa.processor.core.exception.ODataJPAKeyPairException;
import com.sap.olingo.jpa.processor.core.testmodel.BusinessPartner;
import com.sap.olingo.jpa.processor.core.testmodel.BusinessPartnerRole;
import com.sap.olingo.jpa.processor.core.util.TestBase;
import com.sap.olingo.jpa.processor.core.util.TestHelper;

Expand All @@ -45,9 +47,9 @@ class JPAExpandJoinQueryTest extends TestBase {
private EntityManager em;
private JPAODataRequestContextAccess requestContext;
private TestHelper helper;
private JPAKeyPair orgPair;
private JPAKeyPair organizationPair;
private JPAKeyPair adminPair;
private Optional<JPAKeyBoundary> orgBoundary;
private Optional<JPAKeyBoundary> organizationBoundary;
private Optional<JPAKeyBoundary> adminBoundary;
@SuppressWarnings("rawtypes")
private Map<JPAAttribute, Comparable> simpleKey;
Expand All @@ -58,8 +60,8 @@ void setup() throws ODataException {
helper = new TestHelper(emf, PUNIT_NAME);
em = emf.createEntityManager();
requestContext = mock(JPAODataRequestContextAccess.class);
orgPair = new JPAKeyPair(helper.getJPAEntityType("Organizations").getKey());
orgBoundary = Optional.of(new JPAKeyBoundary(1, orgPair));
organizationPair = new JPAKeyPair(helper.getJPAEntityType("Organizations").getKey());
organizationBoundary = Optional.of(new JPAKeyBoundary(1, organizationPair));
adminPair = new JPAKeyPair(helper.getJPAEntityType("AdministrativeDivisions").getKey());
adminBoundary = Optional.of(new JPAKeyBoundary(1, adminPair));
final JPAServiceDebugger debugger = mock(JPAServiceDebugger.class);
Expand All @@ -74,9 +76,19 @@ void setup() throws ODataException {
}

@Test
void testSelectAllWithAllExpand() throws ODataException {
void testSelectDistinctExpand() throws ODataException {
// .../BusinessPartnerRoles?$expand=BusinessPartner($select=ID;$expand=Roles)
final JPAInlineItemInfo item = createBusinessParterRolesExpandChildrenParent(null, null);
cut = new JPAExpandJoinQuery(OData.newInstance(), item, requestContext, Optional.empty());
final JPAExpandQueryResult act = cut.execute();
assertEquals(7, act.getNoResults());
assertEquals(11, act.getNoResultsDeep());
}

@Test
void testSelectOrganizationByIdWithAllExpand() throws ODataException {
// .../Organizations?$expand=Roles&$format=json
final JPAInlineItemInfo item = createOrgExpandRoles(null, null);
final JPAInlineItemInfo item = createOrganizationExpandRoles(null, null);
cut = new JPAExpandJoinQuery(OData.newInstance(), item, requestContext, Optional.empty());
final JPAExpandQueryResult act = cut.execute();
assertEquals(4, act.getNoResults());
Expand All @@ -92,7 +104,7 @@ void testSelectOrgByIdWithAllExpand() throws ODataException {
when(key.getText()).thenReturn("'2'");
final List<UriParameter> keyPredicates = new ArrayList<>();
keyPredicates.add(key);
final JPAInlineItemInfo item = createOrgExpandRoles(keyPredicates, null);
final JPAInlineItemInfo item = createOrganizationExpandRoles(keyPredicates, null);

cut = new JPAExpandJoinQuery(OData.newInstance(), item, requestContext, Optional.empty());
final JPAExpandQueryResult act = cut.execute();
Expand All @@ -103,9 +115,9 @@ void testSelectOrgByIdWithAllExpand() throws ODataException {
@Test
void testSelectWithMinBoundary() throws ODataException {
// .../Organizations?$expand=Roles&$skip=2&$format=json
final JPAInlineItemInfo item = createOrgExpandRoles(null, null);
final JPAInlineItemInfo item = createOrganizationExpandRoles(null, null);
setSimpleKey(3);
cut = new JPAExpandJoinQuery(OData.newInstance(), item, requestContext, orgBoundary);
cut = new JPAExpandJoinQuery(OData.newInstance(), item, requestContext, organizationBoundary);
final JPAExpandQueryResult act = cut.execute();
assertTrue(cut.getSQLString().contains(".\"ID\" = ?"));
assertEquals(1, act.getNoResults());
Expand All @@ -128,10 +140,10 @@ void testSelectWithMinBoundaryEmbedded() throws ODataException {
@Test
void testSelectWithMinMaxBoundary() throws ODataException {
// .../Organizations?$expand=Roles&$top=3&$format=json
final JPAInlineItemInfo item = createOrgExpandRoles(null, null);
final JPAInlineItemInfo item = createOrganizationExpandRoles(null, null);
setSimpleKey(2);
setSimpleKey(1);
cut = new JPAExpandJoinQuery(OData.newInstance(), item, requestContext, orgBoundary);
cut = new JPAExpandJoinQuery(OData.newInstance(), item, requestContext, organizationBoundary);
final JPAExpandQueryResult act = cut.execute();
assertTrue(cut.getSQLString().contains(".\"ID\" >= ?"));
assertTrue(cut.getSQLString().contains(".\"ID\" <= ?"));
Expand Down Expand Up @@ -162,7 +174,7 @@ void testSelectWithMinMaxBoundaryEmbeddedOnlyLastDiffers() throws ODataException
@Test
void testSQLStringNotEmptyAfterExecute() throws ODataException {
// .../Organizations?$expand=Roles&$format=json
final JPAInlineItemInfo item = createOrgExpandRoles(null, null);
final JPAInlineItemInfo item = createOrganizationExpandRoles(null, null);
cut = new JPAExpandJoinQuery(OData.newInstance(), item, requestContext, Optional.empty());
assertTrue(cut.getSQLString().isEmpty());
cut.execute();
Expand Down Expand Up @@ -209,7 +221,49 @@ private JPAInlineItemInfo createAdminDivExpandChildren(final List<UriParameter>
return item;
}

private JPAInlineItemInfo createOrgExpandRoles(final List<UriParameter> keyPredicates,
private JPAInlineItemInfo createBusinessParterRolesExpandChildrenParent(final List<UriParameter> keyPredicates,
final Expression<Boolean> expression) throws ODataJPAModelException, ODataApplicationException {

// .../BusinessPartnerRoles?$expand=BusinessPartner($select=ID;$expand=Roles)

final JPAEntityType et = helper.getJPAEntityType(BusinessPartnerRole.class);
final JPAEntityType buPaEt = helper.getJPAEntityType(BusinessPartner.class);

final JPAExpandItemWrapper uriInfo = mock(JPAExpandItemWrapper.class);
final UriResourceEntitySet uriEts = mock(UriResourceEntitySet.class);
when(uriEts.getKeyPredicates()).thenReturn(keyPredicates);
final EdmEntityType edmType = mock(EdmEntityType.class);
final EdmEntitySet edmSet = mock(EdmEntitySet.class);

final List<JPANavigationPropertyInfo> hops = new ArrayList<>();
hops.add(new JPANavigationPropertyInfo(helper.sd, uriEts, et.getAssociationPath(
"BusinessPartner"), null));
hops.add(new JPANavigationPropertyInfo(helper.sd, buPaEt.getAssociationPath(
"Roles"), null, buPaEt));
hops.add(new JPANavigationPropertyInfo(helper.sd, null, null, et));

final JPAInlineItemInfo item = mock(JPAInlineItemInfo.class);
final UriResourceNavigation target = mock(UriResourceNavigation.class);
final EdmNavigationProperty targetProperty = mock(EdmNavigationProperty.class);
when(targetProperty.getName()).thenReturn("Roles");
when(target.getProperty()).thenReturn(targetProperty);
final List<UriResource> resourceParts = new ArrayList<>();
resourceParts.add(target);

when(item.getEntityType()).thenReturn(et);
when(item.getUriInfo()).thenReturn(uriInfo);
when(item.getHops()).thenReturn(hops);
when(item.getExpandAssociation()).thenReturn(buPaEt.getAssociationPath("Roles"));
when(uriInfo.getUriResourceParts()).thenReturn(resourceParts);
when(uriEts.getType()).thenReturn(edmType);
when(uriEts.getEntitySet()).thenReturn(edmSet);
when(edmSet.getName()).thenReturn("BusinessPartnerRoles");
when(edmType.getNamespace()).thenReturn(PUNIT_NAME);
when(edmType.getName()).thenReturn("BusinessPartnerRole");
return item;
}

private JPAInlineItemInfo createOrganizationExpandRoles(final List<UriParameter> keyPredicates,
final Expression<Boolean> expression) throws ODataJPAModelException, ODataApplicationException {

final JPAEntityType et = helper.getJPAEntityType("BusinessPartnerRoles");
Expand Down Expand Up @@ -252,7 +306,7 @@ private JPAInlineItemInfo createOrgExpandRoles(final List<UriParameter> keyPredi
private void setSimpleKey(final Integer value) throws ODataJPAModelException, ODataJPAKeyPairException {
simpleKey = new HashMap<>(1);
simpleKey.put(helper.getJPAEntityType("Organizations").getKey().get(0), value);
orgPair.setValue(simpleKey);
organizationPair.setValue(simpleKey);
}

private void setComplexKey(final String key1, final String key2, final String key3)
Expand Down
2 changes: 1 addition & 1 deletion jpa/odata-jpa-spring-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>

<artifactId>odata-jpa-spring-support</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jpa/odata-jpa-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>odata-jpa-test</artifactId>
<name>odata-jpa-test</name>
Expand Down
2 changes: 1 addition & 1 deletion jpa/odata-jpa-vocabularies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.sap.olingo</groupId>
<artifactId>odata-jpa</artifactId>
<version>2.1.0</version>
<version>2.1.1</version>
</parent>
<artifactId>odata-jpa-vocabularies</artifactId>
<name>odata-jpa-vocabularies</name>
Expand Down
Loading