我遇到的情况,在我要通过null
通过Java中的SQL参数,但我正在逐渐SQLGrammarException
。如果我传递一些价值,它工作正常。请指导如果我错了某处。如何将null传递给SQL中的SQL参数?
下面是我的代码:
StringBuffer query;
query = new StringBuffer(
"SELECT * "+
"FROM table(package.func(travel_type => travel_search_type("+
"travel_place_no => :travelPlaceNo"+
")))");
Query query1 = em.createNativeQuery(query.toString());
query1.setParameter("travelPlaceNo",null);
searchresults = query1.getResultList();
例外:
org.hibernate.exception.SQLGrammarException
这是我通过SQL开发人员做的,它工作得很好:
SELECT *
FROM table(package.func(travel_type => travel_search_type(
travel_place_no => NULL))) ;
请指导。
还有一个,after:travelPlaceNo - 是复制粘贴错误还是不行? –
我很抱歉这是copuy粘贴而缩进..纠正 – sTg
你看看http://stackoverflow.com/questions/2123438/hibernate-how-to-set-null-query-parameter-value-with- hql? –