`

如何处理Hibernate的 fails to correctly determine parameter type异常

阅读更多

在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 initializ

    Concurrent Manager Fails to Start With Error Could not initialize the Service Manager FNDSM_{HOSTNAME}_{SID}(Doc ID 735148.1)

    Oracle Database on Linux Fails to Start - ORA-27154 ORA-27300 OR

    Oracle Database on Linux Fails to Start - ORA-27154 ORA-27300 ORA-27301 ORA-27302: failure occurred at: sskgpbitsper (Doc ID 2789636.1)

    NIST SP800-54.pdf

    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 ...

    Bochs - The cross platform IA-32 (x86) emulator

    - 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 ...

    Delphi7.1 Update

    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 ...

    微软内部资料-SQL性能优化3

    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笔记

    Python学习笔记,简单易懂,上手快,这里这个东西花了哥2天时间!

    Google C++ Style Guide(Google C++编程规范)高清PDF

    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 ...

    Windows_Networking_Troubleshooting

    Determine the common causes of networking problems and how to avoid them Troubleshoot network connection problems Manage networking for Windows virtual machines Keep the mobile or BYOD worker ...

    springframework.5.0.12.RELEASE

    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 ...

    hiana_-_28_03_20_captainqdn_encryption_AgainAgain_

    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 ...

    显示DLL里的函数名depends22_x86

    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 ...

    VA2333.rar

    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...

    Information dashboard design: the effective visual communication of data

    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...

    CMOS+Electronics+-+How+It+Works,+How+It+Fails

    If you find the mysteries and varieties of integrated circuit failures challenging, then this book if for you.

    椭圆拟合matlab代码

    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, ...

    Python Web Scraping Cookbook: Over 90 proven recipes to get you scraping with Py

    throttling, pagination, and different status codesBuild robust scraping pipelines with SQS and RabbitMQScrape assets such as images media and know what to do when Scraper fails to runExplore ETL ...

    微软内部资料-SQL性能优化2

    A reference to an invalid page (a page that is not in your working set) is referred to as a page fault. Assuming the page reference does not result in an access violation, a page fault can be either ...

    Practical Web Scraping for Data Science.pdf

    Seeing a program working for the first time as it reaches out on the web and starts gathering data never fails to provide a certain rush, feeling like you’ve circumvented the “normal way” of ...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 ...telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss ... 各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ ... 命令和参数之间必需用空格隔...

Global site tag (gtag.js) - Google Analytics