比如说mybatis中可以根据某个参数是否为空来决定是否需要某个sql片段
<if test='arg != NULL'>
and field=#{arg}
</if>
这样,不知道hibernate中有神马好的办法实现这样的功能?
Query中有个方法叫做setProperties(Map map),将条件放入map,就不用自己拼了
------------------------------
/**
* Bind the values of the given Map for each named parameters of the query,
* matching key names with parameter names and mapping value types to
* Hibernate types using hueristics.
* @param bean a java.util.Map
*/
public Query setProperties(Map bean) throws HibernateException;
------------------------------