无法在Spring Boot的NamedQuery中设置null值

时间:2018-12-31 16:45:49

标签: spring-boot spring-data-jpa

我正在发送null值作为JPA NamedQuery的参数,并遇到运行时错误org.hibernate.exception.SQLGrammarException: could not extract ResultSet

要接受null的值,我已经在NamedQuery中设置了(:publishStatusName is null OR t.publish_status_name=:publishStatusName)

代码:Springboot版本:2.1.1

    @NamedNativeQueries({
        @NamedNativeQuery(name="CatalogView.dataTest", query="SELECT t.spid as spid,t.catalog_id as catalogId,t.title_eng as titleEng from {h-schema}catalog_view t WHERE t.locations=:locations AND (:publishStatusName is null OR t.publish_status_name=:publishStatusName)",resultSetMapping="searchResult")
    })

我的存储库中的方法

 public Set<SearchResult> dataTest(@Param("locations") String locations,@Param("publishStatusName") String publishStatusName);

通过myRepository.dataTest(location,null)呼叫

0 个答案:

没有答案