JPA 2 (implém. Hibernate) : bean entité invisible
Bonjour à tous.
J'ai JBoss 6.4,
OpenJDK 1.7 et des poussières,
une base HSQLDB qui tourne bien,
et un DataSource correctement configuré dans JBoss, et dans mon fichier persistence.xml qui se trouve sous META-INF.
Jusqu'ici tout va à merveille.
J'ai créé une classe Budy, déclarée avec @Entity et @Table(name="budies").
Elle a un constructeur vide, des getters, des setters,
tout ce qu'il faut, et pourtant JBoss prétend que mon bean entité n'existe pas :
13:18:32,662 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) java.lang.IllegalArgumentException: Unknown entity: org.gfarny.ejb3.EntityBudy
En principe, nous sommes dans JPA 2, les fichiers de mapping d'hibernate ne sont pas obligatoires et les annotations suffisent...
à tout hasard, voici ici ma classe et persitence.xml, si quelque chose vous semble anormal, merci de me le préciser :
Code:
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
| package org.gfarny.ejb3;
// (imports)
@Entity
@Table(name="budies")
public class EntityBudy {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="id", nullable=false)
private int id;
@Column(name="first", length=30, nullable=false)
private String first;
@Column(name="family", length=30, nullable=false)
private String family;
@Column(name="born")
@Temporal(TemporalType.DATE)
private Date born;
@OneToMany(mappedBy="entityBudy", cascade={CascadeType.REMOVE})
private Set<EntityBudyPhone> entityBudyPhoneSet = new HashSet<EntityBudyPhone>();
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFirst() {
return first;
}
public void setFirst (String f) {
this.first = f;
}
public String getFamily() {
return family;
}
public void setFamily(String f) {
this.family = f;
}
public Date getBorn() { return born; }
public void setBorn(Date dte) {
this.born = dte;
}
public EntityBudy() {}
public EntityBudy(String fst, String fam) {
setFirst(fst);
setFamily(fam);
}
public EntityBudy(String fst, String fam, Date dte) {
setFirst(fst);
setFamily(fam);
setBorn(dte);
}
public Set<EntityBudyPhone> getEntityBudyPhoneSet() {
return entityBudyPhoneSet;
}
// adding to Set is delegated to EntityBudyPhone.new()
public void addEntityBudyPhone(EntityPhone ep) {
new EntityBudyPhone(this, ep);
}
public boolean equals(EntityBudy b) {
if (this.first == b.getFirst())
if (this.family == b.getFamily())
if (this.born == b.getBorn())
return true;
return false;
}
} |
persistence.xml
Code:
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
| <?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="jpa" transaction-type="RESOURCE_LOCAL">
<!-- provider -->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<!-- Classes persistantes -->
<property name="hibernate.archive.autodetection" value="class, hbm" />
<!-- logs SQL
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="use_sql_comments" value="true"/>
-->
<!-- connexion JDBC -->
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbc.JDBCDriver" />
<!-- <property name="hibernate.connection.url" value="jdbc:hsqldb:file:/opt/data/lag;ifexists=true" /> -->
<!-- start HSQLDB Server (README.txt) -->
<property name="hibernate.connection.url" value="jdbc:hsqldb:hsql://localhost/lag;ifexists=true" />
<property name="hibernate.connection.username" value="LAG" />
<property name="hibernate.connection.password" value="LAG" />
<!-- création automatique du schéma -->
<!-- <property name="hibernate.hbm2ddl.auto" value="create" /> -->
<!-- Dialecte -->
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
<!-- propriétés DataSource c3p0 -->
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="300" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="3000" />
</properties>
</persistence-unit>
</persistence> |
D'ailleurs en passant, Hibernate n'utilise plus c3p0, mais c'est une autre question.
Merci d'avance.