[
https://issues.apache.org/jira/browse/OLINGO-28?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13855604#comment-13855604
]
Chandan V.A commented on OLINGO-28:
-----------------------------------
Hello Carl
I have implemented this feature with one constraint. The constraint is that the
Java class's simple Name used as the return type in a function import should
match with EDM Complex Type's Name.
For Example:
If you have defined an EDM complex Type with Name as "OrderValue" then, define
a Java class (Non JPA Entity) that shall act as a data container for Complex
Types with name as OrderValue like below. The class should follow the JavaBeans
style property accessor as well.
public class OrderValue {
private double amount;
private String currency;
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
}
The Java method used as EDM function Import shall look like
@EdmFunctionImport(returnType = @ReturnType(type = Type.COMPLEX))
public OrderValue getOrderValue(
@EdmFunctionImportParameter(name = "SoId", facets = @EdmFacets(nullable =
false)) final Long soID) {
....
If this constraint is not satisfied then the OData2 - JPA processor library
will not be able to identify the Complex Type while parsing the FunctionImports
and this shall result in an exception.
Secondly the EDM built from JPA models can be extended with new Entity Types,
Complex Types and also the existing EDM elements can be modified. See the class
-
org.apache.olingo.odata2.jpa.processor.ref.extension.SalesOrderProcessingExtension
for more details.
I hope this implementation would address your use case.
Thanks
Regards
Chandan
> enhance JPAEdmExtension to support complex types outside the JPA meta model
> ---------------------------------------------------------------------------
>
> Key: OLINGO-28
> URL: https://issues.apache.org/jira/browse/OLINGO-28
> Project: Olingo
> Issue Type: Improvement
> Components: odata2-jpa
> Affects Versions: V2 1.1.0
> Environment: any/all
> Reporter: Carl J. Mosca
> Assignee: Chandan V.A
> Labels: JPA
>
> Support for complex types which exist outside the JPA meta model are needed
> as return types for imported functions
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)