在Hibernate的HQL 中想使用类似下面的 code
"(:param IS NULL OR alias.someField = :param)"
将会抛出determine parameter type 的异常。
把 "(:param IS NULL OR alias.someField = :param)"
换成
"(alias.someField = :param OR :param IS NULL)".
就没有问题了。
2011- 12 -08 补充:
似乎还是不够。
更改了顺序之后 ,直接传入null 似乎还是不行。
使用下面的代码应该是可以。
public List findByNamedQuery(String queryName, String[] paramNames, Object[] paramValues) {
if (paramNames.length != paramValues.length) {
throw new IllegalArgumentException();
}
Map<String, Object> map = new java.util.HashMap<String, Object>(paramNames.length);
for (int i = 0; i < paramNames.length; ++i) {
map.put(paramNames[i], paramValues[i]);
}
return getJpaTemplate().findByNamedQueryAndNamedParams(queryName, map);
}
List findByNamedQuery = findByNamedQuery("findXXXByNameandDateRange",
new String[] { "aName","startDate","endDate" },
new Object[] {
aName,
(startDate==null ? "" : startDate) ,
(endDate==null ? "" : endDate)
});
暂时没有时间仔细调试, 仅供展开 思路。 虽然 集成测试暂时没有问题了。
分享到:
相关推荐
Concurrent Manager Fails to Start With Error Could not initialize the Service Manager FNDSM_{HOSTNAME}_{SID}(Doc ID 735148.1)
在本文中,我们将深入探讨一个特定的Oracle数据库在Linux环境下启动失败的问题,涉及错误代码ORA-27154、ORA-27300、ORA-27301和ORA-27302,这些错误通常与系统信号量相关。此问题可能发生在尝试启动一个新的数据库...
BGP is a routing protocol, whose purpose is to keep systems on the Internet up to date with information needed to receive and transmit traffic correctly. Sending and receiving email, viewing Web ...
- Determine and select max physical address size automatically at configure time: - 32-bit physical address for 386/486 guests - 36-bit physical address for PSE-36 enabled Pentium guest - 40-bit ...
When using a TimeStamp type parameter with a TClientDataSet an error occurs when the parameter is passed to the server (Quality Central 6372). * Setting MTSDataModule.AutoComplete to False in the IDE ...
This removes the requirement to examine every row or page lock on the table to determine whether a transaction can lock the entire table. Lock Mode The code shown in the slide represents how the ...
Python学习笔记,简单易懂,上手快,这里这个东西花了哥2天时间!
Naming General Naming Rules File Names Type Names Variable Names Constant Names Function Names Namespace Names Enumerator Names Macro Names Exceptions to Naming Rules Comments Comment Style File ...
Equals checks to MediaType.ALL should not be affected the presence of parameters [SPR-17550] #22082 Reactive HTTP header adapters don't print header values in toString [SPR-17546] #22078 Add ability ...
I have the problem whare the task scheduler in services is set to automatice but fails to start and log in is greyed out. I have tried many solutions and none have worked. However I did find a ...
通过这篇《SSH异常总结》的分析,开发者可以对SSH异常有更深入的理解,并在实际工作中更有效地处理这些问题。未来,开发者们在进行SSH开发和维护时,应持续关注可能出现的异常,不断总结和优化处理流程,从而提升...
It the language specific resource DLL fails to load, then the module defaults to using the local resources in itself. In most cases, these default resources are the same resources as would be in the ...
Visual Assist is not completely loaded if its toolbar begins with disabled icons, its tool windows are empty, or it fails to responds to its commands in an editor window. • **New!** Added command to...
在微信小程序的云开发环境中,开发者经常会遇到"Check Authorization Fails, Date Expire!"的错误提示,这通常意味着用户授权的凭证已经过期,导致无法正常访问或操作云资源。这个错误不仅影响用户体验,也可能阻碍...
Foreign Key Constraint Fails(亲测可用).md
And if a dashboard fails to tell you precisely what you need to know in an instant, you'll never use it, even if it's filled with cute gauges, meters, and traffic lights. Don't let your investment in...
If you find the mysteries and varieties of integrated circuit failures challenging, then this book if for you.
If it fails to converge, it fails gracefully (with a warning), returning the linear least squares estimate used to derive the start value [z, a, b, alpha] = fitellipse(x) plotellipse(z, a, b, ...