I am creating one example which demonstrates relationship in liferay.I am taking example of Book entity and Author for many to many relationship.I am following below blog for creating this example.
http://www.liferaysavvy.com/2014/01/liferay-service-builder-many-to-many_12.html
But I faced the issue of class cast exception.In blog also it has been written that it is throwing class cast exception.
11:05:00,422 ERROR [RuntimePageImpl-2][render_portlet_jsp:132] null
java.lang.ClassCastException: com.ds.portlet.library.model.impl.AuthorImpl cannot be cast to com.ds.portlet.library.model.Author
at com.ds.portlet.library.service.persistence.AuthorPersistenceImpl.fetchByPrimaryKey(AuthorPersistenceImpl.java:691)
at com.ds.portlet.library.service.persistence.AuthorPersistenceImpl.findByPrimaryKey(AuthorPersistenceImpl.java:653)
at com.ds.portlet.library.service.persistence.AuthorPersistenceImpl.findByPrimaryKey(AuthorPersistenceImpl.java:59)
at com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice.invoke(ShardPersistenceAdvice.java:54)
at com.liferay.portal.service.persistence.impl.TableMapperImpl.getBaseModels(TableMapperImpl.java:400)
at com.liferay.portal.service.persistence.impl.TableMapperImpl.getRightBaseModels(TableMapperImpl.java:265)
at com.ds.portlet.library.service.persistence.BookPersistenceImpl.getAuthors(BookPersistenceImpl.java:1183)
at com.ds.portlet.library.service.persistence.BookPersistenceImpl.getAuthors(BookPersistenceImpl.java:1162)
at com.ds.portlet.library.service.persistence.BookPersistenceImpl.getAuthors(BookPersistenceImpl.java:1143)
at com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice.invoke(ShardPersistenceAdvice.java:54)
at com.ds.portlet.library.service.base.AuthorLocalServiceBaseImpl.getBookAuthors(AuthorLocalServiceBaseImpl.java:374)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
at com.ds.portlet.library.service.AuthorLocalServiceUtil.getBookAuthors(AuthorLocalServiceUtil.java:321)
at org.apache.jsp.view_jsp._jspService(view_jsp.java:420)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
I would like to know the reason behind this.