-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem in Hibernate many-to-one Foreign key relation
PostPosted: Wed Mar 12, 2008 11:36 am 
Newbie

Joined: Wed Mar 12, 2008 11:16 am
Posts: 15
Hi to all

I am trying Hibernate many-to-one association for foreign key relation for two tables.but i am getting the following error

org.hibernate.MappingException: An association from the table contact_bh refers to an unmapped class: Contact_rvBean

can any one solve this

My code--
First table: contact_rv

PID NOT NULL NUMBER(38)
PNAME VARCHAR2(50)


Second table: contact_bh

EMPID NOT NULL NUMBER(38)
PID NUMBER(38)


I want to have foreign key relation for pid in contact_bh to pid in contact_rv



My mapping files are--
For contact_rv
-----------------------------------------------
<?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="com.mss.Contact_rvBean" table="contact_rv">
<id name="pid" type="int" column="pid">
<generator class="increment"/>
</id>

<property name="pname" column="pname" />
</class>
</hibernate-mapping>

For contact_bh

<?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="com.mss.Contact_bhBean" table="contact_bh">
<id name="empid" type="int" column="empid">
<generator class="increment"/>
</id>

<many-to-one name="pid" class="Contact_rvBean" column="pid"/>
</class>
</hibernate-mapping>


beans are
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package com.mss;

/**
*
* @author miracle
*/
public class Contact_bhBean {
private int empid;
private int pid;
private Contact_rvBean rvbean;

public int getEmpid() {
return empid;
}

public void setEmpid(int empid) {
this.empid = empid;
}

public int getPid() {
return pid;
}

public void setPid(int pid) {
this.pid = pid;
}

public Contact_rvBean getRvbean() {
return rvbean;
}

public void setRvbean(Contact_rvBean rvbean) {
this.rvbean = rvbean;
}

}


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package com.mss;

/**
*
* @author miracle
*/
public class Contact_rvBean {

private int pid;
private String pname;

public

int getPid() {
return pid;
}

public void setPid(int pid) {
this.pid = pid;
}

public String getPname() {
return pname;
}

public void setPname(String pname) {
this.pname = pname;
}
}

Can any one PLz PLz PLz PLzPLzPLzPLz PLzPLz................Help me to come out of this problem

or

Please give complete code for one mapping example.
thanks in advance

raghu


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

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.