2022 Dec 22 12:34 PM
I am trying to create some custom functions in OData V4 using JPA and Hibernate.
I have some sample code from a .NET app which works as expected
[EnableQuery(MaxTop = 100, MaxAnyAllExpressionDepth = 10, MaxExpansionDepth = 10)]
[HttpGet] public IActionResult ByName(string name) {
try {
var names = name.Yield().ToArray(); _
rxapiLogger.LogInformation(LOG_CATEGORY, "Substances by name query", "Starting");
return Ok(_ctx.Substances.Where(s => s.Names.Any( i => names.Contains(i))));
} catch (Exception e) { _
rxapiLogger.LogError(LOG_CATEGORY, "Substances by name query", e.Message, e);
return StatusCode(500);
} finally { _
rxapiLogger.LogInformation(LOG_CATEGORY, "Substances by name query", "Finished");
}
}
Would it be correct saying that this we be the same as named queries in Java?
Please can some one assist with perhaps an example on how to create custom functions for handling complex queries using the SAP OData V4 JPA library