我正在使用 jpa 和 sql server 2008 开发一些东西,但出现以下错误
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Conversion failed when converting date and/or time from character string.
Error Code: 241
Call: SELECT TOP 100 * FROM [database].[dbo].[registro] WHERE (indate between 'Wed Apr 30 01:01:01 COT 2014' and 'Mon May 12 01:01:01 COT 2014') or name like '%and%'
Query: ReadAllQuery(referenceClass=Register sql="SELECT TOP 100 * FROM [database].[dbo].[register] WHERE (indate between 'Wed Apr 30 01:01:01 COT 2014' and 'Mon May 12 01:01:01 COT 2014') or name like '%and%'")
jpa 查询:
Query query = em.createNativeQuery("SELECT TOP 100 * FROM [database].[dbo].[register] WHERE (indate between '"+idate+"' and '"+fdate+"') or name like '%"+name+"%'",Register.class);
有人可以告诉我要更改什么或更好的查询方式。