I called the query statement three times and encountered three errors. 1. date cannot be implicitly converted to binary (during query) 2. varbinary cannot be converted to date3. Conversion from string to date or time fails. (When querying) share some good articles: zhidao. baidu. comlink? Urlt-7cAHd5z0FQngE5fYMieZSug
I called the query statement three times and encountered three errors. 1. date cannot be implicitly converted to binary (during query) 2. varbinary cannot be converted to date 3. Conversion from string to date and/or time fails. Share some good articles: http://zhidao.baidu.com/link? Url = t-7cAHd5z0FQngE5fYMieZSug
When I call a query statement three times, an error occurs three times,
1. date cannot be implicit.ConversionIs binary, (when querying)
2. varbinary cannot be converted to date.
3,
From stringConversionDateAnd/or time,ConversionFailed.
(Query time)
Share some good articles:
Http://zhidao.baidu.com/link? Url = t-7cAHd5z0FQngE5fYMieZSugMcu0zu4Mit-GpZj8N_kQouCz5NDQ17cDvXdRZOgveNdyN1bupwSsg_QlIUWUa
Http://blog.knowsky.com/180534.htm
Http://www.iteye.com/problems/76835
Http://ganjp.iteye.com/blog/987520
For the first method, the solution mentioned above is to change the hibernate ing to timestamp in SQL to convert date to datetime.
The second solution is similar to the first solution.
The third type is the most speechless. in java, dateTypeDefault EnglishType(Although bothDateTypeThe representation is not the same, Fri Apr 11 00:00:00 CST 2014 ). Can be converted to YYYY--MM-DD HH-MM-SS this but note that this is StringType! We query the database with date as the condition. Generally, you should write the query condition function.
Public List Find_courseBy (int Stuid, Date Cor_date, String AMPM );
The query statement generated by hibernate is:
select register0_.Cor_id as Cor1_0_, register0_.Stuid as Stuid0_, register0_.Cor_date as Cor3_0_, register0_.Zhou as Zhou0_, register0_.Week as Week0_, register0_.AMPM as AMPM0_, register0_.FirstCor as FirstCor0_, register0_.SecCor as SecCor0_, register0_.Intime as Intime0_, register0_.Outtime as Outtime0_, register0_.R_Result as R11_0_, register0_.R_Sign as R12_0_, register0_.Inpic as Inpic0_, register0_.Outpic as Outpic0_ from T_Course register0_ where register0_.Stuid='220' and register0_.Cor_date='Fri Apr 11 00:00:00 CST 2014' and register0_.AMPM='PM'
Note that it is not in English
Type! So it will be reported (but when I create a query statement in the database
DateIt cannot be queried, but '2017-4-4'
TypeBut the query function can be found.
Date
TypeChange to String
DateConvert to String perfect query !)
Error
From stringConversionDateAnd/or time,ConversionFailed
register0_.Cor_date='Fri Apr 11 00:00:00 CST 2014'