-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: problème avec hibernate 4
PostPosted: Mon Jan 19, 2015 5:49 pm 
Newbie

Joined: Mon Jan 19, 2015 5:40 pm
Posts: 1
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);
}
}
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.