Я делаю и интеграционный тест, который вызывает сервис, который, в свою очередь, вызывает репозиторий, там у меня есть запрос JPQL, который работает в prod (MySQL), но не в интеграционном тесте (h2).
Если возможно, я бы хотел, чтобы решение отличалось от установки запроса на native, поскольку это было бы неоптимальным.
@Query("SELECT vrf " +
"FROM GoogleRequiredField vrf INNER JOIN vrf.googleRequiredFieldProducts p " +
"INNER JOIN vrf.googleRequiredFieldOperations o " +
"INNER JOIN vrf.googleRequiredFieldLanguages l " +
"WHERE p.product = :product and o.operation = :operation and l.locale = :locale ")
Исключением является следующий
WARN o.h.e.j.s.SqlExceptionHelper - SQL Error: 42001, SQLState: 42001
ERROR o.h.e.j.s.SqlExceptionHelper - Syntax error in SQL statement "SELECT GOOGLEREQU0_.FIELD_ID AS FIELD_ID6_16_0_, GOOGLEREQU0_.ID AS ID1_16_0_, GOOGLEREQU0_.ID AS ID1_16_1_, GOOGLEREQU0_.CREATED_ON AS CREATED_2_16_1_, GOOGLEREQU0_.FIELD_ID AS FIELD_ID6_16_1_, GOOGLEREQU0_.LAST_MODIFIED AS LAST_MOD3_16_1_, GOOGLEREQU0_.ORDER[*] AS ORDER4_16_1_, GOOGLEREQU0_.PRODUCT AS PRODUCT5_16_1_ FROM GOOGLE_VRF_FIELD_PRODUCT GOOGLEREQU0_ WHERE GOOGLEREQU0_.FIELD_ID=? "; expected "identifier"; SQL statement:
select googlerequ0_.field_id as field_id6_16_0_, googlerequ0_.id as id1_16_0_, googlerequ0_.id as id1_16_1_, googlerequ0_.created_on as created_2_16_1_, googlerequ0_.field_id as field_id6_16_1_, googlerequ0_.last_modified as last_mod3_16_1_, googlerequ0_.order as order4_16_1_, googlerequ0_.product as product5_16_1_ from google_vrf_field_product googlerequ0_ where googlerequ0_.field_id=? [42001-197]
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement
Спасибо!