ClassCastException while implementing Many to many mapping with Liferay Service Builder

与世无争的帅哥 提交于 2019-12-12 04:01:35

问题


I am trying to implement many to many mapping with liferay service builder. I have found one blog on liferay savvy which explains how to implement it and provides a war file as well.

You can download from here.

It gets deployed successfully and also allows you to create student and courses along with their mapping.

After adding some dummy data when I try to fetch courses based on student id with

List<Course> studentCourseList = CourseLocalServiceUtil.getStudentCourses(xxxx)

where xxxx is student id captured from meera_students_courses table. and then iterating it over for loop

for(Course course : studentCourseList){
 ...
 }

I got java.lang.ClassCastException: com.meera.db.model.impl.CourseImpl cannot be cast to com.meera.db.model.Course exception.

I have checked the list size and it gives proper count. So iteration of the list where casting happens, gives above exception.

Any help on this is appreciated.

来源:https://stackoverflow.com/questions/32334402/classcastexception-while-implementing-many-to-many-mapping-with-liferay-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!