Salut
voila j'ai un problème à faire l'ajout dans la base j'ai voulu utilisé la notion de l’héritage en ejb3 mais j'ai ce message comme erreur
java.lang.IllegalArgumentException: Object: ejbetheritage.Personne[id=1] is not a known entity type.
voila monde code
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
/
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="type",discriminatorType=DiscriminatorType.STRING,length=40)
@Table(name = "personne")
@NamedQueries({
    @NamedQuery(name = "Personne.findAll", query = "SELECT p FROM Personne p"),
    @NamedQuery(name = "Personne.findById", query = "SELECT p FROM Personne p WHERE p.id = :id"),
    @NamedQuery(name = "Personne.findByNom", query = "SELECT p FROM Personne p WHERE p.nom = :nom")})
public class Personne implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "nom")
    private String nom;
 
    public Personne() {
    }
 
    public Personne(Integer id) {
        this.id = id;
    }
 
    public Integer getId() {
        return id;
    }
 
    public void setId(Integer id) {
        this.id = id;
    }
 
    public String getNom() {
        return nom;
    }
 
    public void setNom(String nom) {
        this.nom = nom;
    }
 
 
 
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }
 
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Personne)) {
            return false;
        }
        Personne other = (Personne) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }
 
    @Override
    public String toString() {
        return "ejbetheritage.Personne[id=" + id + "]";
    }
 
}
classe qui hérite de personne
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
@Entity
@DiscriminatorValue("Personne")
public class Prof extends Personne{
 
    public Prof() {
    }
 
    Prof(int i) {
        super(i);
    }
 
}
code de mon main
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
 public static void main(String[] args) {
 
try{
        EntityManager emd= Persistence.createEntityManagerFactory("EjbEtHeritagePU").createEntityManager();
        Prof p= new Prof(2);
        p.setNom("Test");
        emd.persist(p);
        System.out.println("Ajout bien fait");
 
        }catch(Exception e){
 
         System.out.println(e);
        } 
 
    }
voila s'il vous comment résoudre ce problème
merci d’avance