diff --git a/.xmake.cfg b/.xmake.cfg
new file mode 100644
index 000000000..81923357f
--- /dev/null
+++ b/.xmake.cfg
@@ -0,0 +1,6 @@
+[xmake]
+xmake-version=0.9.2-MS8
+[buildplugin]
+java-type=sapmachine
+alternate-path=jpa
+java-version=17.0.8
diff --git a/README.md b/README.md
index daa3c9d4b..818678563 100644
--- a/README.md
+++ b/README.md
@@ -102,5 +102,5 @@ Detailed information including third-party components and their licensing/copyri
|2.1.0| - Enhancement of annotation API
- Enhancement of API for server driven paging
- Optional support of IN operand
- Update to Olingo 5.0.0
- Rework $count implementation
- 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.1.3| - Fix for issue [#319](https://github.com/SAP/olingo-jpa-processor-v4/issues/319)
- Fix for issue [#325](https://github.com/SAP/olingo-jpa-processor-v4/issues/325)
- Fix for issue [#327](https://github.com/SAP/olingo-jpa-processor-v4/issues/327)
- Fix for issue [#331](https://github.com/SAP/olingo-jpa-processor-v4/issues/331)
- Fix of en issue with $orderby and _to one_ navigation properties |No|
-|2.2.0| - Fix for issue [#378](https://github.com/SAP/olingo-jpa-processor-v4/issues/378)
- Fix for issue [#378](https://github.com/SAP/olingo-jpa-processor-v4/issues/378)
- Fix for issue [#361](https://github.com/SAP/olingo-jpa-processor-v4/issues/361)
- Fix for issue [#352](https://github.com/SAP/olingo-jpa-processor-v4/issues/352)
- Fix for issue [#307](https://github.com/SAP/olingo-jpa-processor-v4/issues/307)
- Enhancement according to [#314](https://github.com/SAP/olingo-jpa-processor-v4/issues/314)|No|
+|2.2.0| - Fix for issue [#378](https://github.com/SAP/olingo-jpa-processor-v4/issues/378)
- Fix for issue [#361](https://github.com/SAP/olingo-jpa-processor-v4/issues/361)
- Fix for issue [#352](https://github.com/SAP/olingo-jpa-processor-v4/issues/352)
- Fix for issue [#307](https://github.com/SAP/olingo-jpa-processor-v4/issues/307)
- Enhancement according to [#314](https://github.com/SAP/olingo-jpa-processor-v4/issues/314)|No|
|2.3.0| - Add support for handling multiple API version. Issue [#308](https://github.com/SAP/olingo-jpa-processor-v4/issues/308)
- Fix for issue [#359](https://github.com/SAP/olingo-jpa-processor-v4/issues/359)
- Fix for issue [#406](https://github.com/SAP/olingo-jpa-processor-v4/issues/406)
- Fix for issue [#397](https://github.com/SAP/olingo-jpa-processor-v4/issues/397)|No|
diff --git a/jpa-archetype/odata-jpa-archetype-spring/pom.xml b/jpa-archetype/odata-jpa-archetype-spring/pom.xml
index c62b63bc1..739ec7950 100644
--- a/jpa-archetype/odata-jpa-archetype-spring/pom.xml
+++ b/jpa-archetype/odata-jpa-archetype-spring/pom.xml
@@ -4,7 +4,7 @@
com.sap.olingo
odata-jpa-archetype
- 2.3.1-SNAPSHOT
+ 2.3.1-SNAPSHOT
odata-jpa-archetype-spring
Archetype - odata-jpa-archetype-spring
diff --git a/jpa-archetype/pom.xml b/jpa-archetype/pom.xml
index 244b22cba..294f593f9 100644
--- a/jpa-archetype/pom.xml
+++ b/jpa-archetype/pom.xml
@@ -10,10 +10,10 @@
UTF-8
- 17
+ 17
- odata-jpa-archetype-spring
+ odata-jpa-archetype-spring
\ No newline at end of file
diff --git a/jpa-tutorial/Questions/HowToHandleApiVersions.adoc b/jpa-tutorial/Questions/HowToHandleApiVersions.adoc
index 7388847d2..79101124f 100644
--- a/jpa-tutorial/Questions/HowToHandleApiVersions.adoc
+++ b/jpa-tutorial/Questions/HowToHandleApiVersions.adoc
@@ -103,7 +103,7 @@ public abstract class EclipseLinkJpaConfiguration extends JpaBaseConfiguration {
----
Then we need to create the version specific entity manager factories.
-Please note that with each version of the entity manager factory we also have to create a transaction manager.
+Please note that with each version of the entity manager factory we also have to create a transaction manager and must have an own persistence unit name.
It is also important that one of the beans for the factory has the name `entityManagerFactory`.
First the entity manager factory for the old version:
@@ -136,6 +136,7 @@ public class JpaConfigurationV1 extends EclipseLinkJpaConfiguration {
return basicSettings(factoryBuilder)
.packages(Trip.class, PlanItem.class, OffsetDateTimeConverter.class)
+ .persistenceUnit("TrippinV1")
.build();
}
}
@@ -176,6 +177,7 @@ public class JpaConfigurationV2 extends EclipseLinkJpaConfiguration {
return basicSettings(factoryBuilder)
.packages(Trip.class, PlanItem.class, OffsetDateTimeConverter.class)
+ .persistenceUnit("TrippinV2")
.build();
}
}
diff --git a/jpa-tutorial/Questions/Preparation.adoc b/jpa-tutorial/Questions/Preparation.adoc
index 38f0b45e1..4f39dd8c9 100644
--- a/jpa-tutorial/Questions/Preparation.adoc
+++ b/jpa-tutorial/Questions/Preparation.adoc
@@ -290,7 +290,7 @@ insert into "Person" values ('keithpinckney', 'Keith', 'Pinckney', null, 0, null
insert into "Person" values ('marshallgaray', 'Marshall', 'Garay', null, 0, null);
insert into "Person" values ('ryantheriault', 'Ryan', 'Theriault', null, 0, null);
insert into "Person" values ('elainestewart', 'Elaine', 'Stewart', null, 0, null);
-insert into "Person" values ('salliesampson', 'Sallie', 'Sampson', null, 1, null);
+insert into "Person" values ('sallysampson', 'Sally', 'Sampson', null, 1, null);
insert into "Person" values ('jonirosales', 'Joni', 'Rosales', null, 2, null);
insert into "Person" values ('georginabarlow', 'Georgina', 'Barlow', null, 1, null);
insert into "Person" values ('angelhuffman', 'Angel', 'Huffman', null, 1, null);
@@ -326,7 +326,7 @@ insert into "Trip" values (11, 'keithpinckney', 'a88f675d-9199-4392-9656-b08e3b4
insert into "Trip" values (12, 'marshallgaray', 'a88f675d-9199-4392-9656-b08e3b46df8a', 'Study trip', 1550.3, 'This is a 2 weeks study trip', '2014-01-01T00:00:00Z', '2014-01-14T00:00:00Z');
insert into "Trip" values (13, 'ryantheriault', 'a88f675d-9199-4392-9656-b08e3b46df8a', 'Study trip', 1550.3, 'This is a 2 weeks study trip', '2014-01-01T00:00:00Z', '2014-01-14T00:00:00Z');
insert into "Trip" values (14, 'elainestewart', 'a88f675d-9199-4392-9656-b08e3b46df8a', 'Study trip', 1550.3, 'This is a 2 weeks study trip', '2014-01-01T00:00:00Z', '2014-01-14T00:00:00Z');
-insert into "Trip" values (15, 'salliesampson', 'a88f675d-9199-4392-9656-b08e3b46df8a', 'Study trip', 600, 'This is a 2 weeks study trip', '2014-01-01T00:00:00Z', '2014-01-14T00:00:00Z');
+insert into "Trip" values (15, 'sallysampson', 'a88f675d-9199-4392-9656-b08e3b46df8a', 'Study trip', 600, 'This is a 2 weeks study trip', '2014-01-01T00:00:00Z', '2014-01-14T00:00:00Z');
insert into "Trip" values (16, 'jonirosales', 'a88f675d-9199-4392-9656-b08e3b46df8a', 'Study trip', 2000, 'This is a 2 weeks study trip', '2014-01-01T00:00:00Z', '2014-01-14T00:00:00Z');
insert into "Trip" values (17, 'georginabarlow', 'a88f675d-9199-4392-9656-b08e3b46df8a', 'Study trip', 1150.3, 'This is a 2 weeks study trip', '2014-01-01T00:00:00Z', '2014-01-14T00:00:00Z');
insert into "Trip" values (18, 'angelhuffman', 'cb0b8acb-79cb-4127-8316-772bc4302824', 'DIY Trip', 1500.3, 'This is a DIY trip', '2011-02-11T00:00:00Z', '2011-02-14T00:00:00Z');
diff --git a/jpa-tutorial/QuickStart/QuickStart.adoc b/jpa-tutorial/QuickStart/QuickStart.adoc
index e8b5157df..2ec74d9be 100644
--- a/jpa-tutorial/QuickStart/QuickStart.adoc
+++ b/jpa-tutorial/QuickStart/QuickStart.adoc
@@ -46,7 +46,7 @@ This should contain the information about archetype:
com.sap.olingo
odata-jpa-archetype-spring
- 2.1.3
+ 2.3.0
diff --git a/jpa/.dbeaver/credentials-config.json b/jpa/.dbeaver/credentials-config.json
new file mode 100644
index 000000000..3156ea04c
--- /dev/null
+++ b/jpa/.dbeaver/credentials-config.json
@@ -0,0 +1 @@
+:b694E˗JA8/gU{~=eVZ̘8a\;}q6+2`kuN)ɪW_=/^;o|sI5':%0GfRt
f}:\s:4n[\K$UYGrUSj3?EDeuΧ,>\@#7pZ;,H>WQyRϚ@Y`VqVڹlauz-\hD%_>Ci-lp-0?W`ogjwg_HV:%OI@$lm_J%fKx1tPC}c4hw;Eŋwg\VmDZ&`F@ׅlKEGiE`ttډ<,Oz)qznuoW4)[+iD?FY2([]n'ڣ&
\ No newline at end of file
diff --git a/jpa/.dbeaver/data-sources.json b/jpa/.dbeaver/data-sources.json
new file mode 100644
index 000000000..473b37c41
--- /dev/null
+++ b/jpa/.dbeaver/data-sources.json
@@ -0,0 +1,116 @@
+{
+ "folders": {},
+ "connections": {
+ "postgres-jdbc-18d652c2b95-113570e0ec869f1d": {
+ "provider": "postgresql",
+ "driver": "postgres-jdbc",
+ "name": "postgres",
+ "save-password": true,
+ "configuration": {
+ "host": "localhost",
+ "port": "5432",
+ "database": "postgres",
+ "url": "jdbc:postgresql://localhost:5432/postgres",
+ "configurationType": "MANUAL",
+ "home": "postgresql-x64-16",
+ "type": "dev",
+ "closeIdleConnection": false,
+ "auth-model": "native"
+ }
+ },
+ "postgres-jdbc-18d7dab8ffc-6870c0ec5fa5f049": {
+ "provider": "postgresql",
+ "driver": "postgres-jdbc",
+ "name": "Olingo",
+ "save-password": true,
+ "configuration": {
+ "host": "localhost",
+ "port": "5432",
+ "database": "Olingo",
+ "url": "jdbc:postgresql://localhost:5432/Olingo",
+ "configurationType": "MANUAL",
+ "home": "postgresql-x64-16",
+ "type": "dev",
+ "closeIdleConnection": false,
+ "auth-model": "native"
+ }
+ },
+ "sap_hana-18d83921104-7dd425d3aee15bf1": {
+ "provider": "hana",
+ "driver": "sap_hana",
+ "name": "localhost",
+ "save-password": true,
+ "configuration": {
+ "host": "localhost",
+ "port": "30015",
+ "url": "jdbc:sap://localhost:30015",
+ "configurationType": "MANUAL",
+ "type": "dev",
+ "closeIdleConnection": false,
+ "provider-properties": {
+ "edition": "GENERIC"
+ },
+ "auth-model": "native"
+ }
+ },
+ "postgres-jdbc-18dec2e5845-6df665f2f5a08171": {
+ "provider": "postgresql",
+ "driver": "postgres-jdbc",
+ "name": "compass",
+ "save-password": true,
+ "configuration": {
+ "host": "localhost",
+ "port": "5432",
+ "database": "compass",
+ "url": "jdbc:postgresql://localhost:5432/compass",
+ "configurationType": "MANUAL",
+ "home": "postgresql-x64-16",
+ "type": "dev",
+ "closeIdleConnection": true,
+ "provider-properties": {
+ "@dbeaver-show-non-default-db@": "false"
+ },
+ "auth-model": "native"
+ }
+ },
+ "mysql8-18f81c6ea39-153fa1c6870708de": {
+ "provider": "mysql",
+ "driver": "mysql8",
+ "name": "MySql-Olingo",
+ "save-password": true,
+ "configuration": {
+ "host": "localhost",
+ "port": "3306",
+ "database": "Olingo",
+ "url": "jdbc:mysql://localhost:3306/Olingo?allowPublicKeyRetrieval=true&useSSL=false",
+ "configurationType": "URL",
+ "home": "mysql_client",
+ "type": "dev",
+ "closeIdleConnection": true,
+ "properties": {
+ "rewriteBatchedStatements": "true",
+ "connectTimeout": "20000",
+ "enabledTLSProtocols": "TLSv1,TLSv1.1,TLSv1.2,TLSv1.3"
+ },
+ "auth-model": "native",
+ "handlers": {}
+ }
+ }
+ },
+ "connection-types": {
+ "dev": {
+ "name": "Development",
+ "color": "255,255,255",
+ "description": "Regular development database",
+ "auto-commit": true,
+ "confirm-execute": false,
+ "confirm-data-change": false,
+ "smart-commit": false,
+ "smart-commit-recover": false,
+ "auto-close-transactions": true,
+ "close-transactions-period": 1800,
+ "auto-close-connections": true,
+ "close-connections-period": 14400
+ }
+ }
+}
\ No newline at end of file
diff --git a/jpa/.dbeaver/project-metadata.json b/jpa/.dbeaver/project-metadata.json
new file mode 100644
index 000000000..205c91a6d
--- /dev/null
+++ b/jpa/.dbeaver/project-metadata.json
@@ -0,0 +1 @@
+{"resources":{"Scripts/Script-1.sql":{"default-schema":"OLINGO","default-datasource":"postgres-jdbc-18d7dab8ffc-6870c0ec5fa5f049","default-catalog":"Olingo"},"Scripts/Script-10.sql":{"default-schema":"OLINGO","default-datasource":"postgres-jdbc-18d7dab8ffc-6870c0ec5fa5f049","default-catalog":"Olingo"},"Scripts/Script-11.sql":{"default-schema":"OLINGO","default-datasource":"sap_hana-18d83921104-7dd425d3aee15bf1"},"Scripts/Script-12.sql":{"default-schema":"public","default-datasource":"postgres-jdbc-18dec2e5845-6df665f2f5a08171","default-catalog":"compass"},"Scripts/Script-13.sql":{"default-datasource":"sap_hana-18d83921104-7dd425d3aee15bf1","default-schema":"OLINGO"},"Scripts/Script-2.sql":{"default-schema":"OLINGO","default-datasource":"sap_hana-18d83921104-7dd425d3aee15bf1","default-catalog":"compass"},"Scripts/Script-3.sql":{"default-schema":"OLINGO","default-datasource":"sap_hana-18d83921104-7dd425d3aee15bf1","default-catalog":"Olingo"},"Scripts/Script-4.sql":{"default-schema":"OLINGO","default-datasource":"postgres-jdbc-18d7dab8ffc-6870c0ec5fa5f049","default-catalog":"Olingo"},"Scripts/Script-5.sql":{"default-schema":"OLINGO","default-datasource":"postgres-jdbc-18d7dab8ffc-6870c0ec5fa5f049","default-catalog":"Olingo"},"Scripts/Script-6.sql":{"default-schema":"public","default-datasource":"postgres-jdbc-18dec2e5845-6df665f2f5a08171","default-catalog":"compass"},"Scripts/Script-7.sql":{"default-schema":"public","default-datasource":"postgres-jdbc-18dec2e5845-6df665f2f5a08171","default-catalog":"compass"},"Scripts/Script-8.sql":{"default-schema":"public","default-datasource":"postgres-jdbc-18dec2e5845-6df665f2f5a08171","default-catalog":"compass"},"Scripts/Script-9.sql":{"default-schema":"public","default-datasource":"postgres-jdbc-18dec2e5845-6df665f2f5a08171","default-catalog":"compass"},"Scripts/Script.sql":{"default-schema":"OLINGO","default-datasource":"sap_hana-18d83921104-7dd425d3aee15bf1","default-catalog":"Olingo"}}}
\ No newline at end of file
diff --git a/jpa/.dbeaver/project-settings.json b/jpa/.dbeaver/project-settings.json
new file mode 100644
index 000000000..0e2242aaf
--- /dev/null
+++ b/jpa/.dbeaver/project-settings.json
@@ -0,0 +1 @@
+{"id":"1dc9dc18-395d-49be-a7b8-2ad9bb1a4481"}
\ No newline at end of file
diff --git a/jpa/.gitignore b/jpa/.gitignore
index 465424a3d..f932957a7 100644
--- a/jpa/.gitignore
+++ b/jpa/.gitignore
@@ -11,4 +11,4 @@ target/
*.log
/old.project
/Scripts/
-/.dbeaver/
+/.dbeaver/
\ No newline at end of file
diff --git a/jpa/.project b/jpa/.project
index 942c0feae..cf9aeda0a 100644
--- a/jpa/.project
+++ b/jpa/.project
@@ -24,6 +24,7 @@
org.eclipse.jdt.core.javanature
org.eclipse.m2e.core.maven2Nature
+ org.jkiss.dbeaver.DBeaverNature
diff --git a/jpa/odata-jpa-coverage/pom.xml b/jpa/odata-jpa-coverage/pom.xml
index 61d938d58..3d24b34fd 100644
--- a/jpa/odata-jpa-coverage/pom.xml
+++ b/jpa/odata-jpa-coverage/pom.xml
@@ -10,7 +10,6 @@
odata-jpa-coverage
odata-jpa-coverage
https://github.com/SAP/olingo-jpa-processor-v4
-
com.sap.olingo
diff --git a/jpa/odata-jpa-metadata/old.project b/jpa/odata-jpa-metadata/old.project
new file mode 100644
index 000000000..ba05291b0
--- /dev/null
+++ b/jpa/odata-jpa-metadata/old.project
@@ -0,0 +1,47 @@
+
+
+ jpa-metadata
+
+
+
+
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+ org.eclipse.wst.common.project.facet.core.nature
+
+
+
+ 1634102235525
+
+ 30
+
+ org.eclipse.core.resources.regexFilterMatcher
+ node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
+
+
+
+
diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAEntityType.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAEntityType.java
index 42e89afef..06e9b87dc 100644
--- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAEntityType.java
+++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/api/JPAEntityType.java
@@ -61,6 +61,12 @@ public interface JPAEntityType extends JPAStructuredType, JPAAnnotatable {
*/
public boolean hasCompoundKey();
+ /**
+ * True in case the entity type has an EmbeddedId
+ * @return
+ */
+ public boolean hasEmbeddedKey();
+
/**
* @return a list of JPAPath to attributes marked with EdmSearchable
* @throws ODataJPAModelException
diff --git a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityType.java b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityType.java
index e15381d83..54522ae49 100644
--- a/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityType.java
+++ b/jpa/odata-jpa-metadata/src/main/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityType.java
@@ -295,6 +295,12 @@ public boolean hasCompoundKey() {
|| idType instanceof EmbeddableType;
}
+ @Override
+ public boolean hasEmbeddedKey() {
+ return ((IdentifiableType>) jpaManagedType).hasSingleIdAttribute()
+ && hasCompoundKey();
+ }
+
@Override
public boolean hasEtag() throws ODataJPAModelException {
buildEdmTypeIfEmpty();
diff --git a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityTypeTest.java b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityTypeTest.java
index 8c1cfe60b..1135f7386 100644
--- a/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityTypeTest.java
+++ b/jpa/odata-jpa-metadata/src/test/java/com/sap/olingo/jpa/metadata/core/edm/mapper/impl/IntermediateEntityTypeTest.java
@@ -677,6 +677,27 @@ void checkIdIsNotCompound() {
assertFalse(et.hasCompoundKey());
}
+ @Test
+ void checkEmbeddedIdKeyIsEmbedded() {
+ final IntermediateEntityType et = new IntermediateEntityType<>(
+ new JPADefaultEdmNameBuilder(PUNIT_NAME), getEntityType(AdministrativeDivisionDescription.class), schema);
+ assertTrue(et.hasEmbeddedKey());
+ }
+
+ @Test
+ void checkMultipleKeyIsNotEmbedded() {
+ final IntermediateEntityType et = new IntermediateEntityType<>(new JPADefaultEdmNameBuilder(
+ PUNIT_NAME), getEntityType(AdministrativeDivision.class), schema);
+ assertFalse(et.hasEmbeddedKey());
+ }
+
+ @Test
+ void checkIdIsNotEmbedded() {
+ final IntermediateEntityType et = new IntermediateEntityType<>(new JPADefaultEdmNameBuilder(
+ PUNIT_NAME), getEntityType(BusinessPartner.class), schema);
+ assertFalse(et.hasEmbeddedKey());
+ }
+
@Test
void checkEntityWithMappedSuperClassContainsAllProperties() throws ODataJPAModelException {
final IntermediateEntityType et = new IntermediateEntityType<>(new JPADefaultEdmNameBuilder(PUNIT_NAME),
diff --git a/jpa/odata-jpa-processor/old.project b/jpa/odata-jpa-processor/old.project
new file mode 100644
index 000000000..1fd67ec03
--- /dev/null
+++ b/jpa/odata-jpa-processor/old.project
@@ -0,0 +1,47 @@
+
+
+ jpa-processor
+
+
+
+
+
+ org.eclipse.wst.common.project.facet.core.builder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jem.workbench.JavaEMFNature
+ org.eclipse.wst.common.modulecore.ModuleCoreNature
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+ org.eclipse.wst.common.project.facet.core.nature
+
+
+
+ 1634102235540
+
+ 30
+
+ org.eclipse.core.resources.regexFilterMatcher
+ node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__
+
+
+
+
\ No newline at end of file
diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataQueryDirectives.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataQueryDirectives.java
index 6b66f0c6e..8fc256798 100644
--- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataQueryDirectives.java
+++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataQueryDirectives.java
@@ -10,19 +10,28 @@ public static JPAODataQueryDirectivesBuilder with(final Builder builder) {
int getMaxValuesInInClause();
- static record JPAODataQueryDirectivesImpl(int maxValuesInInClause) implements JPAODataQueryDirectives {
+ UuidSortOrder getUuidSortOrder();
+
+ static record JPAODataQueryDirectivesImpl(int maxValuesInInClause, UuidSortOrder uuidSortOrder) implements
+ JPAODataQueryDirectives {
@Override
public int getMaxValuesInInClause() {
return maxValuesInInClause;
}
+ @Override
+ public UuidSortOrder getUuidSortOrder() {
+ return uuidSortOrder;
+ }
+
}
static class JPAODataQueryDirectivesBuilderImpl implements JPAODataQueryDirectivesBuilder {
private final Builder parent;
private int maxValuesInInClause = 0;
+ private UuidSortOrder uuidSortOrder = UuidSortOrder.AS_STRING;
JPAODataQueryDirectivesBuilderImpl(final Builder builder) {
this.parent = builder;
@@ -36,7 +45,20 @@ public JPAODataQueryDirectivesBuilder maxValuesInInClause(final int maxValues) {
@Override
public JPAODataServiceContextBuilder build() {
- return parent.setQueryDirectives(new JPAODataQueryDirectivesImpl(maxValuesInInClause));
+ return parent.setQueryDirectives(new JPAODataQueryDirectivesImpl(maxValuesInInClause, uuidSortOrder));
+ }
+
+ @Override
+ public JPAODataQueryDirectivesBuilder uuidSortOrder(final UuidSortOrder order) {
+ this.uuidSortOrder = order;
+ return this;
}
}
+
+ public enum UuidSortOrder {
+ AS_STRING,
+ AS_BYTE_ARRAY,
+ AS_JAVA_UUID;
+ }
+
}
diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataQueryDirectivesBuilder.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataQueryDirectivesBuilder.java
index 674e3496a..95392f47b 100644
--- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataQueryDirectivesBuilder.java
+++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataQueryDirectivesBuilder.java
@@ -1,9 +1,13 @@
package com.sap.olingo.jpa.processor.core.api;
+import com.sap.olingo.jpa.processor.core.api.JPAODataQueryDirectives.UuidSortOrder;
+
public interface JPAODataQueryDirectivesBuilder {
JPAODataQueryDirectivesBuilder maxValuesInInClause(int i);
+ JPAODataQueryDirectivesBuilder uuidSortOrder(UuidSortOrder order);
+
JPAODataServiceContextBuilder build();
}
\ No newline at end of file
diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContext.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContext.java
index 7c1a27f9b..bb44bcba3 100644
--- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContext.java
+++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/JPAODataServiceContext.java
@@ -106,6 +106,7 @@ public JPAODataDatabaseOperations getOperationConverter() {
return operationConverter;
}
+ @Override
public JPAODataPagingProvider getPagingProvider() {
return pagingProvider;
}
diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandler.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandler.java
index c9f4830c9..471929bbd 100644
--- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandler.java
+++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/api/example/JPAExampleCUDRequestHandler.java
@@ -84,7 +84,8 @@ public Object createEntity(final JPARequestEntity requestEntity, final EntityMan
em.persist(instance);
}
} else {
- // POST on Link only // https://issues.oasis-open.org/browse/ODATA-1294
+ // POST on Link only
+ // https://issues.oasis-open.org/browse/ODATA-1294
instance = findEntity(requestEntity, em);
}
processRelatedEntities(requestEntity.getRelatedEntities(), instance, requestEntity.getModifyUtil(), em);
@@ -109,14 +110,16 @@ public JPAUpdateResult updateEntity(final JPARequestEntity requestEntity, final
final HttpMethod method) throws ODataJPAProcessException {
if (method == HttpMethod.PATCH || method == HttpMethod.DELETE) {
- final Object instance = em.find(requestEntity.getEntityType().getTypeClass(), requestEntity.getModifyUtil()
+ Object instance = em.find(requestEntity.getEntityType().getTypeClass(), requestEntity.getModifyUtil()
.createPrimaryKey(requestEntity.getEntityType(), requestEntity.getKeys(), requestEntity.getEntityType()));
- if (instance == null) throw new JPAExampleModifyException(ENTITY_NOT_FOUND, HttpStatusCode.NOT_FOUND);
- requestEntity.getModifyUtil().setAttributesDeep(requestEntity.getData(), instance, requestEntity.getEntityType());
+ if (instance == null) {
+ instance = createOneEntity(requestEntity, null);
+ requestEntity.getModifyUtil().setPrimaryKey(requestEntity.getEntityType(), requestEntity.getKeys(), instance);
- updateLinks(requestEntity, em, instance);
- setAuditInformation(instance, requestEntity.getClaims(), false);
- return new JPAUpdateResult(false, instance);
+ return new JPAUpdateResult(true, instance);
+ } else {
+ return updateFoundEntity(requestEntity, em, instance);
+ }
}
return super.updateEntity(requestEntity, em, method);
}
@@ -128,6 +131,16 @@ public void validateChanges(final EntityManager em) throws ODataJPAProcessExcept
processBindingLinks(entity.getValue().getRelationLinks(), entity.getKey(), entity.getValue().getModifyUtil(), em);
}
+ private JPAUpdateResult updateFoundEntity(final JPARequestEntity requestEntity, final EntityManager em,
+ final Object instance) throws ODataJPAProcessorException, ODataJPAInvocationTargetException {
+ requestEntity.getModifyUtil().setAttributesDeep(requestEntity.getData(), instance, requestEntity
+ .getEntityType());
+
+ updateLinks(requestEntity, em, instance);
+ setAuditInformation(instance, requestEntity.getClaims(), false);
+ return new JPAUpdateResult(false, instance);
+ }
+
private void checkAuthorizationsOneClaim(final JPAProtectionInfo protectionInfo, final Object value,
final List> pairs) throws JPAExampleModifyException {
boolean match = false;
diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAModifyUtil.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAModifyUtil.java
index cd5be773c..eca048a81 100644
--- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAModifyUtil.java
+++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPAModifyUtil.java
@@ -6,6 +6,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
@@ -86,6 +87,7 @@ Map buildSetterList(@Nonnull final Class> type,
*
* @param et
* @param jpaKeys
+ * @param st
* @return
* @throws ODataJPAProcessorException
*/
@@ -129,6 +131,40 @@ public Object createPrimaryKey(final JPAEntityType et, final Object instance) th
}
}
+ /**
+ * Fills the key properties in instance. This is helpful e.g. for Upserts.
+ * Setter for the key attributes are required.
+ * @param et Metadata describing the entity type
+ * @param jpaKeys Map of key properties
+ * @param instance Instance of the JPA entity to be filled
+ * @throws ODataJPAProcessorException
+ */
+ public void setPrimaryKey(final JPAEntityType et, final Map jpaKeys, final Object instance)
+ throws ODataJPAProcessorException {
+ try {
+ if (et.hasEmbeddedKey()) {
+ final Object key = et.getKeyType().getConstructor().newInstance();
+ for (final JPAAttribute keyElement : et.getKey()) {
+ setAttribute(key, keyElement, jpaKeys.get(keyElement.getInternalName()));
+ }
+ final var setter = Arrays.stream(instance.getClass().getMethods())
+ .filter(method -> method.getParameterCount() == 1
+ && method.getParameters()[0].getType() == et.getKeyType())
+ .findAny();
+ if (setter.isPresent()) {
+ setter.get().invoke(instance, key);
+ }
+ } else {
+ for (final var key : et.getKey()) {
+ setAttribute(instance, key, jpaKeys.get(key.getInternalName()));
+ }
+ }
+ } catch (NoSuchMethodException | SecurityException | IllegalAccessException
+ | IllegalArgumentException | InvocationTargetException | InstantiationException | ODataJPAModelException e) {
+ throw new ODataJPAProcessorException(e, HttpStatusCode.INTERNAL_SERVER_ERROR);
+ }
+ }
+
/**
* Sets a link between a source and target instance. Prerequisite are
* existing setter and getter on the level of the sourceInstance. In case of to n associations it is expected that the
@@ -424,7 +460,8 @@ private void setEmbeddedAttributeDeep(final Object instance, final JPAStructured
}
@SuppressWarnings("unchecked")
- private void setEmbeddedCollectionAttributeDeep(final Object instance, final JPAStructuredType st, final Method method,
+ private void setEmbeddedCollectionAttributeDeep(final Object instance, final JPAStructuredType st,
+ final Method method,
final Object value, final Class>[] parameters, final JPAAttribute attribute)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException,
ODataJPAModelException, ODataJPAProcessorException, ODataJPAInvocationTargetException {
diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPANavigationRequestProcessor.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPANavigationRequestProcessor.java
index 800363746..bc1f0ef8b 100644
--- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPANavigationRequestProcessor.java
+++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/processor/JPANavigationRequestProcessor.java
@@ -213,8 +213,8 @@ JPAETagValidationResult validateEntityTag(final JPAConvertibleResult result, fin
return JPAETagValidationResult.SUCCESS;
}
- boolean isRootResultEmpty(JPAConvertibleResult result) {
- if (result instanceof JPAExpandResult expandResult) {
+ private boolean isRootResultEmpty(final JPAConvertibleResult result) {
+ if (result instanceof final JPAExpandResult expandResult) {
return expandResult.getResult(ROOT_RESULT_KEY).isEmpty();
}
return false;
diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/properties/JPAAbstractProcessorAttributeImpl.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/properties/JPAAbstractProcessorAttributeImpl.java
index 21d269bb4..1d3868711 100644
--- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/properties/JPAAbstractProcessorAttributeImpl.java
+++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/properties/JPAAbstractProcessorAttributeImpl.java
@@ -81,4 +81,9 @@ public boolean requiresJoin() {
return !hops.isEmpty();
}
+ @Override
+ public JPAPath getJPAPath() {
+ return path;
+ }
+
}
diff --git a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/properties/JPAProcessorAttribute.java b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/properties/JPAProcessorAttribute.java
index 7948ea141..1b7b3330f 100644
--- a/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/properties/JPAProcessorAttribute.java
+++ b/jpa/odata-jpa-processor/src/main/java/com/sap/olingo/jpa/processor/core/properties/JPAProcessorAttribute.java
@@ -11,6 +11,7 @@
import jakarta.persistence.criteria.Order;
import jakarta.persistence.criteria.Path;
+import com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath;
import com.sap.olingo.jpa.processor.core.exception.ODataJPAQueryException;
public interface JPAProcessorAttribute {
@@ -75,4 +76,6 @@ JPAProcessorAttribute setTarget(@Nonnull final From, ?> target, @Nonnull final
*/
Path