Bonjour,

Lorsque je souhaite insérer un enregistrement dans une table (très simple) dont voici le descriptif :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
 Nom                                       NULL ?   Type
 ----------------------------------------- -------- -----------
 BIS_ID                                    NOT NULL NUMBER(2)
 BIS_LIBELLE                                        VARCHAR2(20)
j'ai ce message d'erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
ORA-01438: valeur incohérente avec la précision indiquée pour cette colonne
En effet dans les logs de jboss 6, voici les paramètres pour l'insert :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2011-08-25 11:53:12,653 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1) Hibernate: 
2011-08-25 11:53:12,654 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1)     select
2011-08-25 11:53:12,654 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1)         SEQ_BIS.nextval 
2011-08-25 11:53:12,654 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1)     from
2011-08-25 11:53:12,654 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1)         dual

2011-08-25 11:53:12,656 DEBUG [org.hibernate.SQL] (http-localhost%2F127.0.0.1-8080-1) 
    insert 
    into
        BIS
        (BIS_LIBELLE, BIS_ID) 
    values
        (?, ?)
2011-08-25 11:53:12,656 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1) Hibernate: 
2011-08-25 11:53:12,657 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1)     insert 
2011-08-25 11:53:12,657 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1)     into
2011-08-25 11:53:12,657 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1)         BIS
2011-08-25 11:53:12,657 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1)         (BIS_LIBELLE, BIS_ID) 
2011-08-25 11:53:12,657 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1)     values
2011-08-25 11:53:12,657 INFO  [STDOUT] (http-localhost%2F127.0.0.1-8080-1)         (?, ?)

2011-08-25 11:53:12,657 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (http-localhost%2F127.0.0.1-8080-1) binding parameter [1] as [VARCHAR] - ter
2011-08-25 11:53:12,657 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] (http-localhost%2F127.0.0.1-8080-1) binding parameter [2] as [INTEGER] - 1300
2011-08-25 11:53:12,660 WARN  [org.hibernate.util.JDBCExceptionReporter] (http-localhost%2F127.0.0.1-8080-1) SQL Error: 1438, SQLState: 22003
2011-08-25 11:53:12,660 ERROR [org.hibernate.util.JDBCExceptionReporter] (http-localhost%2F127.0.0.1-8080-1) ORA-01438: valeur incohérente avec la précision indiquée pour cette colonne
En effet la colonne BIS_ID est un number(2) donc 1300 pose pb!
Par contre je comprends pas d’où vient cette valeur de 1300, car lorsque je vais directement sous ORACLE pour connaitre la future valeur de la séquence, j'ai 25 :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
SQL> select        SEQ_BIS.nextval     from        dual;
 
   NEXTVAL
----------
        25
J'ai dû oublier un morceau qq part, c'est peut être pour cela qu'il y un pb entre hibernate et oracle.

Voici mon entity
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
import java.io.Serializable;
import javax.persistence.*;
import java.util.Set;
 
@Entity
@SequenceGenerator(name = "seqbis", sequenceName = "SEQ_BIS")
@Table(name="BIS")
public class BisEntity implements Serializable {
	private static final long serialVersionUID = 1L;
 
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqbis")
	@Column(name="BIS_ID")
	private Integer bisId;
 
	@Column(name="BIS_LIBELLE")
	private String bisLibelle;
 
 
    public BisEntity() {
    }
 
    public BisEntity(String libelle) {
    	this.bisLibelle=libelle;
    }
 
	public Integer getBisId() {
		return this.bisId;
	}
 
	public void setBisId(Integer bisId) {
		this.bisId = bisId;
	}
 
	public String getBisLibelle() {
		return this.bisLibelle;
	}
 
	public void setBisLibelle(String bisLibelle) {
		this.bisLibelle = bisLibelle;
	}
}
Voici mon bean
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 
import java.util.ArrayList;
import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.faces.model.SelectItem;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
 
@Stateless
@LocalBean
public class BisBean {
	@PersistenceContext (unitName = "GeriexEJB", name = "GeriexEJB")
	private EntityManager em;
 
	private List<BisEntity> bisList = new ArrayList<BisEntity>();
	private List<SelectItem> bisListSelect = new ArrayList<SelectItem>();
 
    public BisBean() {}
 
    public void ajouter(String libelle){
    	System.out.println("entre dans BISBEAN : "+libelle);
    	BisEntity bis = new BisEntity(libelle);
    	System.out.println("instanciation : "+bis.getBisLibelle().toString());
    	em.persist(bis);
    	em.flush();
    }
 
    public List<SelectItem> listBis(){
    	bisList = em.createQuery("select b from BisEntity b").getResultList();
    	for(BisEntity biss : bisList){
    		bisListSelect.add(new SelectItem(biss.getBisId(), biss.getBisLibelle()));
    	}
    	return bisListSelect;
    }
 
	public EntityManager getEm() {
		return em;
	}
 
	public void setEm(EntityManager em) {
		this.em = em;
	}
 
	public List<BisEntity> getBisList() {
		return bisList;
	}
 
	public void setBisList(List<BisEntity> bisList) {
		this.bisList = bisList;
	}
 
	public List<SelectItem> getBisListSelect() {
		return bisListSelect;
	}
 
	public void setBisListSelect(List<SelectItem> bisListSelect) {
		this.bisListSelect = bisListSelect;
	}
 
}
Mon managed bean:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
 
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.model.SelectItem;
import javax.inject.Named;
 
@Named
@RequestScoped
public class AdministrationController {
	@EJB
	private VilleBean ville;
	private List<SelectItem> villes;
	private String commune;
	private String cp;
	@EJB
	private BisBean bisBean;
	private String bis;
	private List<SelectItem> bisList;
 
 
	public void villeAjouter(){
		ville.ajouter(commune, cp);
	}
 
	public void bisAjouter(){
		bisBean.ajouter(bis);
	}
 
 
	public VilleBean getVille() {
		return ville;
	}
 
	public void setVille(VilleBean ville) {
		this.ville = ville;
	}
 
	public String getCommune() {
		return commune;
	}
 
	public void setCommune(String commune) {
		this.commune = commune;
	}
 
	public String getCp() {
		return cp;
	}
 
	public void setCp(String cp) {
		this.cp = cp;
	}
 
 
	public void setVilles(List<SelectItem> villes) {
		this.villes = villes;
	}
 
 
	public List<SelectItem> getVilles() {
		villes = ville.listVille();
		return villes;
	}
 
	public BisBean getBisBean() {
		return bisBean;
	}
 
	public void setBisBean(BisBean bisBean) {
		this.bisBean = bisBean;
	}
 
	public String getBis() {
		return bis;
	}
 
	public void setBis(String bis) {
		this.bis = bis;
	}
 
	public List<SelectItem> getBisList() {
		bisList = bisBean.listBis();
		return bisList;
	}
 
	public void setBisList(List<SelectItem> bisList) {
		this.bisList = bisList;
	}
 
 
}
J'utilise donc oracle 11g, JSF2, EJB 3.1
Voila si qqn à une idée, merci par avance
Cordialement
couse1