Today, when using hibernate operation, the query operation also made this error. I couldn’t figure out the solution. Finally, I found the ending method on the Internet, which should not be regarded as the method. That’s the reason.
First, I use the following HQL statement
String hql="select new PO(。。。。) from 。。。";
This error is largely due to the time format. The reasons are as follows
1. In Oracle, what is the return time of using hibernate query java.util.Date Yes.
2. When using struts1, the time plug-ins in the foreground must be string in the form, otherwise an error will be reported.
3. Use BeanUtils.copyProperties Method, the string time in form can only be converted to java.sql.Date Type.
4. Due to the reason of 3, the time type of Po entity class should be java.sql.Date Type.
5. Oracle return java.util.Date , Po is java.sql.Date So the problem arises.
The current solution is to transform in the construction method, and another method is to implement string to java.util.Date But what I’m doing now is an old project. There was a lot of code before, and it would be troublesome if I made a mistake. So it’s relatively safe to use the construction method to convert.
We have to make complaints about the problems in our project, which are basically caused by the time type related to the database, and the conflict of jar packages in the project.