-->
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.  [ 4 posts ] 
Author Message
 Post subject: UniDirectional Many-to-One Mapping
PostPosted: Wed Mar 22, 2006 4:03 pm 
Newbie

Joined: Tue Mar 07, 2006 3:57 pm
Posts: 10
I am creating a many-to-one mapping to represent Foreign Key relations.

Tables are like this :

RESPONSE (response_pk, status_fk)

STATUS (status_pk)


This is how I have defined the relationships in response.hbm.xml

<many-to-one name="status"
column = "STATUS_FK"
class="Status"
not-null = "true"/>


I have created getters and setters for Status
public Status getStatus() {
return status;
}

When the run the program, I am getting a MappingException

org.hibernate.MappingException: An association from the table
RESPONSE refers to an unmapped class: com.log.Status
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:968)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:921)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:999)


Any suggestions ?

Thanks in advance

Pooja


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 4:28 pm 
Newbie

Joined: Tue Nov 15, 2005 4:21 am
Posts: 11
You need to add the mapping for class Status, something like:

<class name="Status" table="status">
.....
</class>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 22, 2006 5:07 pm 
Newbie

Joined: Tue Mar 07, 2006 3:57 pm
Posts: 10
I have added that to Status.hbm and also mapped it as a resource in hibernate.cfg.xml


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 23, 2006 4:44 am 
Newbie

Joined: Tue Nov 15, 2005 4:21 am
Posts: 11
Maybe Status is not in package com.log? Someone more experienced with hibernate might be able to help, I'm afraid I can't guess too much without the full mapping documents and classes. Post them if possible. Meanwhile, try copying the mapping of Status.hbm inside Response.hbm and see if it solves the problem, if it does, then Status.hbm is not being read.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.