I have a problem making a mapping association between two classes, in hibernate 3.0
The fisrt one is like
public class ClassA implements Serializable {
private long id;
private String name;
public ClassA() {}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
With a mapping file:
<hibernate-mapping>
<class name="com.ourcompany.ourproyect.ClassA" table="EntityA">
<id name="id" column="A_Id">
<generator class="increment"/>
</id>
<property name="name" type="string" column="A_name"/>
</class>
</hibernate-mapping>
And my second class is like:
public class ClassB implements Serializable {
private long id;
private String name;
private ClassA a;
public ClassB() {}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setB(String name) {
this.name = name;
}
public ClassA getA() {
return a;
}
public void setA(ClassA a) {
this.a = a;
}
}
With a mapping file:
<hibernate-mapping>
<class name="com.ourcompany.ourproyect.ClassB" table="EntityB">
<id name="id" column="B_Id">
<generator class="increment"/>
</id>
<many-to-one name="a" column="A_Id" class="ClassA"/>
</class>
</hibernate-mapping>
I'm creating two tables to map these classes:
CREATE TABLE "EntityA"
(
"A_Id" int8 NOT NULL,
"A_Name" varchar(20),
CONSTRAINT pka PRIMARY KEY ("A_Id")
)
And,
CREATE TABLE "EntidadB"
(
"B_Id" int8 NOT NULL,
"B_Name" varchar(20),
"A_Id" int8 NOT NULL,
CONSTRAINT pkb PRIMARY KEY ("B_Id"),
CONSTRAINT fka FOREIGN KEY ("A_Id")
REFERENCES "EntityA" ("A_Id") MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT
)
...In a PostgreSQL 8.1 database.
I'm building a .har and deploying it in JBoss 4.0.3, but the console dump me the follow error:
--- MBeans waiting for other MBeans ---
ObjectName: com.protantalo.prueba:name=ControlPagosSessionFactory
State: FAILED
Reason: org.hibernate.MappingException: An association from the table EntidadB refers to an unmapped class: ClassA
--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: com.protantalo.prueba:name=ControlPagosSessionFactory
State: FAILED
Reason: org.hibernate.MappingException: An association from the table EntityB refers to an unmapped class: ClassA
What am I doing wrong???
Thank you very much for any help...
|