我正在发送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)
呼叫