-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Example 7.4.1 in Hibernate Reference is not working
PostPosted: Sat Apr 30, 2005 5:39 am 
Newbie

Joined: Fri Apr 29, 2005 11:55 pm
Posts: 14
Location: China-Australia
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 02, 2005 9:04 am 
Beginner
Beginner

Joined: Wed Apr 21, 2004 8:33 am
Posts: 27
As far as i now your mapping file is wrong.
The place wher you have defined the one-to-many association
you have to give reference of the hibernate_unique_key and next_hi
not address ID

check out if this works

thanks and regards
Yenne


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.