JBoss met à disposition des outils Hibernate (Eclipse plugins) simplifiant le mapping relationnel/objet.
La création d'une console Hibernate va permettre d'exécuter des opérations Hibernate, à partir de la console.
Vérifier la création des classes dans le package spécifié.
package net.models;
// Generated 7 avr. 2013 01:39:14 by Hibernate Tools 3.4.0.CR1
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* Produit generated by hbm2java
*/
@Entity
@Table(name = "produit", catalog = "ormH")
public class Produit implements java.io.Serializable {
private Integer id;
private int idCategorie;
private String nom;
private float prix;
public Produit() {
}
public Produit(int idCategorie, String nom, float prix) {
this.idCategorie = idCategorie;
this.nom = nom;
this.prix = prix;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "idCategorie", nullable = false)
public int getIdCategorie() {
return this.idCategorie;
}
public void setIdCategorie(int idCategorie) {
this.idCategorie = idCategorie;
}
@Column(name = "nom", nullable = false)
public String getNom() {
return this.nom;
}
public void setNom(String nom) {
this.nom = nom;
}
@Column(name = "prix", nullable = false, precision = 12, scale = 0)
public float getPrix() {
return this.prix;
}
public void setPrix(float prix) {
this.prix = prix;
}
}