Bonjour tout le monde

j'ai essaié d'utiliser le framework Hibernate avec le mode (SQL natif)

J'ai 2 objet (Composant,Fabricant) Models

je voudrais retouner un composant

Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
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);
	}

mais j'ai une erreur
java.lang.ClassCastException: org.hibernate.internal.SQLQueryImpl cannot be cast to com.JEE.model.Composant
pourtant j'ai suivi le chapitre SQL natif de hibernate chapitre 17 !!!

quelqu'un pourrait-il m'aider ?