Note that there are some explanatory texts on larger screens.

plurals
  1. POExtend class from another extended Parametrized Generic class
    primarykey
    data
    text
    <p>I have a genericService support classes ( genericService, GenericServiceImpl, GenericDao,GenericHibernateDao) for generic service,dao layer. </p> <p>Normaly it works fine, When i extend any type parametrized service from abstract generic services.When i extend this extended services in different service it gives:</p> <p>Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType</p> <p>error.</p> <p>My GEnericHibernateDao:</p> <p>@Transactional public abstract class GenericHibernateDaoSupport extends HibernateDaoSupport implements GenericDaoTemplate { private Class type;</p> <pre><code>public GenericHibernateDaoSupport() { this.type = (Class&lt;T&gt;) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; } @Autowired @Qualifier(value = "productSessionFactory") public void bindSessionFactory(SessionFactory sessionFactory) { setSessionFactory(sessionFactory); } public Class&lt;T&gt; getType() { return type; } public void setType(Class&lt;T&gt; type) { this.type = type; } protected Session getCurrentSession() { return getHibernateTemplate().getSessionFactory().getCurrentSession(); } public ID persist(T newInstance) { return (ID) getHibernateTemplate().save(newInstance); } public void update(T transientObject) { getHibernateTemplate().update(transientObject); } </code></pre> <p>Here is my standart extended HibernateDao class:</p> <pre><code>@Repository public class StandadHibernateDao extends standardHibernateDaoSupport&lt;Standard, Long&gt; implements StandardDao { </code></pre> <p>Above extend operation works fine, But when i tried something like this:</p> <pre><code>@Repository public class ExtendStandardGatewayHibernateDao extends StandadHibernateDao implements ExtendedStandardDao { </code></pre> <p>it throws : </p> <p>Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType.</p> <p>Do you have any idea?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload