Olingo2 version 2.0.11 has problem with spring-boot-starter-web version 2.0.0 or above!
I made an odata service with olingo2
, jpa
Does not solve the original issue and is not the most efficient way.. but here is a workaround for how to remove the incorrect 'escape' statement with only one slash:
public class SqlStatementInspector implements StatementInspector {
private static final long serialVersionUID = 1L;
private static final Logger LOG = Logger.getLogger(SqlStatementInspector.class);
@Override
public String inspect(String sql) {
if (!sql.contains("escape \'\\'")) {
return sql;
}
// OData JPA query correction -> current version (2.0.11) contains
// the invalid 'escape "\"' statement that delivers no results
LOG.info("Replacing invalid statement: escape \"\\\"");
return sql.replace("escape \'\\'", "");
}
}
This overwrites the inspect method and you can modify the generated sql query when using hibernate
in my persistence.xml file i then need to set the property "hibernate.session_factory.statement_inspector" to connect my StatementInspector implementation with my hibernate session factory
<property
name="hibernate.session_factory.statement_inspector"
value="SqlStatementInspector" />
i don't know how exactly this would work with spring-boot but maybe there is a similiar property for your application.properties?