Quelle est la structure de ta table ?
Version imprimable
Quelle est la structure de ta table ?
Champ###Type ##### Interclassement ### Null
---------------------------------------------------
Id #### int(20) ################ # Non
Nom ## varchar(20) # latin1_swedish_ci # Non
Prenom varchar(20) # latin1_swedish_ci # Non
Age ### int(3) ################### Non
ALTER TABLE `table` ADD `Id` INT( 200 ) NOT NULL FIRST ;
ALTER TABLE `table` ADD PRIMARY KEY ( `Id` )
ALTER TABLE `table` ADD `Nom` VARCHAR( 20 ) NOT NULL ;
ALTER TABLE `table` ADD `Prenom` VARCHAR( 20 ) NOT NULL ;
ALTER TABLE `table` ADD `Age` INT( 3 ) NOT NULL ;
Il manque l'Id lors de la persistence de ton objet.
la classe est généré par hibernate synchrinizer, l'Id est bien renseigner :
package hibernate.base;
import java.io.Serializable;
/**
* This class has been automatically generated by Hibernate Synchronizer.
* For more information or documentation, visit The Hibernate Synchronizer page
* at http://www.binamics.com/hibernatesync or contact Joe Hudson at joe@binamics.com.
*
* This is an object that contains data related to the table table.
* Do not modify this class because it will be overwritten if the configuration file
* related to this class is modified.
*
* @hibernate.class
* table="table"
*/
public abstract class BaseTable implements Serializable {
public static String PROP_NOM = "Nom";
public static String PROP_AGE = "Age";
public static String PROP_PRENOM = "Prenom";
public static String PROP_ID = "Id";
private int hashCode = Integer.MIN_VALUE;
// primary key
private java.lang.Integer _id;
// fields
private java.lang.String _nom;
private java.lang.Integer _age;
private java.lang.String _prenom;
// constructors
public BaseTable () {
initialize();
}
/**
* Constructor for primary key
*/
public BaseTable (java.lang.Integer _id) {
this.setId(_id);
initialize();
}
/**
* Constructor for required fields
*/
public BaseTable (
java.lang.Integer _id,
java.lang.String _nom,
java.lang.Integer _age,
java.lang.String _prenom) {
this.setId(_id);
this.setNom(_nom);
this.setAge(_age);
this.setPrenom(_prenom);
initialize();
}
protected void initialize () {}
/**
* Return the unique identifier of this class
* @hibernate.id
* generator-class="native"
* column="Id"
*/
public java.lang.Integer getId () {
return _id;
}
/**
* Set the unique identifier of this class
* @param _id the new ID
*/
public void setId (java.lang.Integer _id) {
this._id = _id;
this.hashCode = Integer.MIN_VALUE;
}
/**
* Return the value associated with the column: Nom
*/
public java.lang.String getNom () {
return _nom;
}
/**
* Set the value related to the column: Nom
* @param _nom the Nom value
*/
public void setNom (java.lang.String _nom) {
this._nom = _nom;
}
/**
* Return the value associated with the column: Age
*/
public java.lang.Integer getAge () {
return _age;
}
/**
* Set the value related to the column: Age
* @param _age the Age value
*/
public void setAge (java.lang.Integer _age) {
this._age = _age;
}
/**
* Return the value associated with the column: Prenom
*/
public java.lang.String getPrenom () {
return _prenom;
}
/**
* Set the value related to the column: Prenom
* @param _prenom the Prenom value
*/
public void setPrenom (java.lang.String _prenom) {
this._prenom = _prenom;
}
public boolean equals (Object obj) {
if (null == obj) return false;
if (!(obj instanceof hibernate.base.BaseTable)) return false;
else {
hibernate.base.BaseTable mObj = (hibernate.base.BaseTable) obj;
if (null == this.getId() || null == mObj.getId()) return false;
else return (this.getId().equals(mObj.getId()));
}
}
public int hashCode () {
if (Integer.MIN_VALUE == this.hashCode) {
if (null == this.getId()) return super.hashCode();
else {
String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
this.hashCode = hashStr.hashCode();
}
}
return this.hashCode;
}
public String toString () {
return super.toString();
}
}
Pas dans la classe table; mais lors de son appel.
PS : n'oublie pas la balise code.
Merci beaucoup pour ton aide ça marche :)