$filter not working in JPA/Olingo 2.0.11 with MySQL

后端 未结 1 1251
遇见更好的自我
遇见更好的自我 2020-12-22 03:30

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

相关标签:
1条回答
  • 2020-12-22 04:09

    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?

    0 讨论(0)
提交回复
热议问题