Jvdev
October 20, 2022, 4:34pm
1
USING Hibernate 5.6.9.Final
I got the following error on the line queryObj.list()
java.lang.ClassCastException: org.hibernate.hql.internal.classic.NamedParameterInformationImpl cannot be cast to java.util.ArrayList
The code is the following
String query = "select tb FROM TAB_1 sb inner join sb.indexes as tb where CONVERT(DATE,sb.v_date) = :odate";
Query queryObj = dao.createQuery(query);
queryObj.setParameter(odate, new SimpleDateFormat("yyyy-MM-dd").format("2022-05-01");
List = queryObj.list();
If I use
new Date()
instead of a specific date, it returns 0 result. Also for other dates, I get 0 result. But for dates that should return results, I get the exception.
beikov
October 21, 2022, 7:13am
2
The code snippet you posted here is not valid Java code, so I have no idea what you are really executing. I also need to see the full stack trace.
Jvdev
October 21, 2022, 3:32pm
3
Okay. This is a the query
select tb FROM TAB_1 sb inner join sb.indexes as tb where CONVERT(DATE,sb.v_date) = :odate
If I do this it works
select tb FROM TAB_1 sb inner join sb.indexes as tb where CONVERT(DATE,sb.v_date) = '2020-10-10'
I spent times debugging and found that data is fetched but the casting fails in this method
org.hibernate.loader.initializeEntitiesandCollections
Here is a full stack track. Deleted lines contain the described method path.
2nd image in next comment
Hibernate properties in next comment
Jvdev
October 21, 2022, 3:33pm
4
Hibernate properties in next comment
Jvdev
October 21, 2022, 3:43pm
5
hibernate properties
PS: metamodel population is disabled as I got the issue “expecting Id class” , disabling it fixed it.
xml config:
beikov
October 21, 2022, 4:06pm
6
That is not a full stack trace. In the first picture, there are <15 internal calls>
which are relevant here. Also, stop posting pictures and post formatted text instead.
Jvdev
October 21, 2022, 7:13pm
8
In fact it is on my work pc and I don’t have the right to login here, share files or send mails that’s why I shared images.
I can only see this way to share my stack.
If you allow it, here is logs + ( added xml config in my last comment)
Image 1 hosted in ImgBB
Image 2 hosted in ImgBB
Thanks
beikov
October 24, 2022, 7:24am
9
Don’t use the org.hibernate.hql.internal.classic.QueryTranslatorImpl
. Remove the configuration of the hibernate.query.factory_class