on 07-28-2023 5:46 PM
Hello all,
I am trying to import the metadata of the official "Condition Contract API" into my Java CAP project. The my compile leads to the error message that the variable is already defined. And that for all entities. Im just using "cds import ../../api.edmx --as cds".
The problem is the following:
For example, the entity CndnContrConditionRecord has the key field "ConditionContract", which becomes "CONDITION_CONTRACT" when compiled. At the same time the entity has the field "_ConditionContract" which also becomes "CONDITION_CONTRACT". Now of course I have a problem.
Is there a trick here? Is this the way it is supposed to be? Is this a bug?
I used the annotation @cds.java.name in another API import, but in this API I have to adjust dozens of fields, and I can imagine that this leads to problems, especially that I want to use the naviogation features.
Thanks!
Hi Tobias,
unfortunately explicitly resolving the conflicts by using the annotation @cds.java.name is the only way to solve this easily at the moment. When using the interfaces this will not be a problem, because internally the methods will still be able to distinguish "ConditionContract" and "_ConditionContract". The Java method name is not really relevant there anymore.
Here is the link to the docs again for @cds.java.name: https://cap.cloud.sap/docs/java/data#renaming-elements-in-java
Best regards,
Marc
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the tip.
Maybe you can help me out a little here.
I want to include the following API: SAP API - Condition Contract
There I have, as already said, several places where I have to rename the navigation with @cds.java.name. I have done that. Now the project could be built with maven. After I included the API in my CDS service file (via using {... as ...} from ...) and expose a entity, the following Java file is created. As you can see, I now get the same string three times. And I am very sure that I defined the name only once... what am I doing wrong?
public interface CndnContrConditionRecord_ extends StructuredType<CndnContrConditionRecord_> {
String NAV_CNDN_CONTR_CNDN_RECD_VALIDITY = "_CndnContrCndnRecdValidity_ConditionContract";
String NAV_CNDN_CONTR_CNDN_RECD_VALIDITY = "_CndnContrCndnRecdValidity_ConditionRecord"; String NAV_CNDN_CONTR_CNDN_RECD_VALIDITY = "_CndnContrCndnRecdValidity_ConditionValidityEndDate";
And of cource I'm getting an error here... 😉
Sure. I uploaded it here.
I have replaced all leading _ in the Associations with Nav*.
I couldn't reproduce the issue unfortunately after adding the CDS file to srv/external and including it using "using { API_CONDITION_CONTRACT } from './external/API_CONDITION_CONTRACT';". Actually there are no String constants generated in the CndnContrConditionRecord_ class at all. Which CAP Java and @sap/cds-dk version are you using?
User | Count |
---|---|
70 | |
9 | |
8 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.