Message d'erreur: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
Code Responsable.java import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table;
/** * Responsable generated by hbm2java */ @Entity @Table(name="RESPONSABLE" ,schema="YAZAKI" ) public class Responsable implements java.io.Serializable {
private long matriculeR; private String nomR; private String prenom; private String login; private String password;
public Responsable() { }
public Responsable(long matriculeR) { this.matriculeR = matriculeR; } public Responsable(long matriculeR, String nomR, String prenom, String login, String password) { this.matriculeR = matriculeR; this.nomR = nomR; this.prenom = prenom; this.login = login; this.password = password; } @Id
@Column(name="MATRICULE_R", unique=true, nullable=false, precision=10, scale=0) public long getMatriculeR() { return this.matriculeR; } public void setMatriculeR(long matriculeR) { this.matriculeR = matriculeR; }
@Column(name="NOM_R", length=50) public String getNomR() { return this.nomR; }
public void setNomR(String nomR) { this.nomR = nomR; }
@Column(name="PRENOM", length=50) public String getPrenom() { return this.prenom; } public void setPrenom(String prenom) { this.prenom = prenom; }
@Column(name="LOGIN", length=150) public String getLogin() { return this.login; } public void setLogin(String login) { this.login = login; }
@Column(name="PASSWORD", length=500) public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; }
code hibernateUTIL public class HibernateUtil {
public static SessionFactory buildSessionFactory(){ try{ Configuration configuration = new Configuration(); configuration.configure(); ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry(); SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry); sessionFactory.openSession(); return sessionFactory; } catch (Throwable ex) { // Log the exception. System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } Methode pour l'insertion : public class methodes { public static void main(String[] args) throws Exception{ Session session= (Session) HibernateUtil.buildSessionFactory(); Transaction TR=null; try{ TR = session.beginTransaction() ; Responsable resp = new Responsable(11,"abdelbacet","mhamdi","lol","lol"); /*resp.setMatriculeR(11); resp.setNomR("Nour"); resp.setPrenom("Prenom"); resp.setLogin("yazaki"); resp.setPassword("yazaki");*/ session.save(resp); session.flush(); TR.commit(); } catch (Exception e) { if (TR != null) { try { TR.rollback(); } catch (HibernateException he) { throw he; } } throw e; } finally { try { session.close(); } catch (HibernateException ex) { throw new Exception(ex); } } } }
|