I tried the example 7.4.1 in Hibernate 3 reference document, it sucks. It's the official document, why its example doesn't work? Can anyone help?
The error I got is
Initial SessionFactory creation failed.org.hibernate.MappingException: An association from the table Person refers to an unmapped class: int
Hibernate version: 3.0.1
Mapping documents:
Note: My mapping document is exactly same as the one on example 7.4.1, except the generator, which is guaranteed correct. (I tested it with another basic form)
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="Person">
<id name="id" column="personId">
<generator class="org.hibernate.id.TableHiLoGenerator">
<param name="table">hibernate_unique_key</param>
<param name="column">next_hi</param>
</generator>
</id>
<many-to-one name="address" column="addressId" not-null="true"/>
</class>
<class name="Address">
<id name="id" column="addressId">
<generator class="org.hibernate.id.TableHiLoGenerator">
<param name="table">hibernate_unique_key</param>
<param name="column">next_hi</param>
</generator>
</id>
<set name="people" inverse="true">
<key column="addressId"/>
<one-to-many class="Person"/>
</set>
</class>
</hibernate-mapping>
[/b]
Again, my database table is exactly same as the one in the example, I copied the query from the document to create my tables
create table Person ( personId bigint not null primary key, addressId bigint not null );
create table Address ( addressId bigint not null primary key );
plus the "hibernate_unique_key" table I've already tested
here's my class file
public class Person{
int id;
int address;
public int getId(){return id;}
public void setId(int id){this.id;}
public getAddress(){return address;}
public setAddress(int address){this.address = address;}
}
public class Address {
int id;
Set people;
public int getId(){return id;}
public void setId(int id){this.id = id;}
public Set getPeople(){return people;}
public void setPeople(Set people){this.people = people;}
}
thanks for any help
|