I tried to follow an example of a book hibernate Chapter 17 SQL native so I summary, I would return an object XXX with a SQL query using Hibernate .. Here is my example
@Override
public Composant FindComposantFRomXls(String comp, String fab) {
return (Composant) getSessionFactory().getCurrentSession().createSQLQuery("select * from composant where ref_composant='"+comp+" ' and fabricant =(select id_fabricant from fabricant where nom_fabricant ='"+fab+"')").addEntity(Composant.class);
}
this is my error message
java.lang.ClassCastException: org.hibernate.internal.SQLQueryImpl cannot be cast to com.JEE.model.Composant