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.  [ 3 posts ] 
Author Message
 Post subject: association references unmapped class
PostPosted: Fri Aug 19, 2005 1:07 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 4:37 pm
Posts: 27
Location: Washington DC
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hi,

I am just trying to do a simple insert with a many-to-one association. I am getting an association references an unmapped class exception.



Hibernate version: 3.0.5

Mapping documents:

hibernate-cfg.xml
<session-factory>

<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@skanchirajulptp:1521:TEST</property>
<property name="connection.username">scott</property>
<property name="connection.password">scott</property>
<property name="connection.schema">scott</property>

<property name="dialect">org.hibernate.dialect.OracleDialect</property>

<property name="show_sql">true</property>

<property name="hbm2ddl.auto">create-drop</property>

<mapping resource="Imdscannedconfig.hbm.xml"/>
<mapping resource="Net.hbm.xml"/>

net.hbm.xml
<class name="com.hibernate.example.pos.Net" table="NETS">

<id name="id" >
<column name="NET_ID" not-null="true"/>
<generator class="sequence"/>
</id>

<property name="name">
<column name="NET_NAME"/>
</property>

<set name="imdscannedconfig"
inverse="true"
cascade="save-update">
<key column="NET_ID"></key>
<one-to-many class="Imdscannedconfig"/>
</set>

</class>

imdscannedconfig.hbm.xml
<class name="com.hibernate.example.pos.Imdscannedconfig" table="IMDSCANNED">

<id name="id">
<column name="IMDS_ID" not-null="true"/>
<generator class="sequence"/>
</id>

<property name="configName">
<column name="IMDS_NAME" length="16" not-null="true"/>
</property>

<many-to-one name="net"
column="NET_ID"
class="Net"
not-null="true"/>
</class>



Code between sessionFactory.openSession() and session.close():

Net testnet = new Net();
testnet.setName("Net 1");
Imdscannedconfig candConfg = new Imdscannedconfig();
candConfg.setConfigName("Test Canned Configuration");
testnet.addImdscannedconfig(candConfg);
sess.save(testNet);

code for addImdscannedconfig()
public void addImdscannedconfig(Imdscannedconfig imdscand)
{
imdscand.setNet(this);
this.getImdscannedconfig().add(imdscand);

}

Full stack trace of any exception that occurs:
java.lang.ExceptionInInitializerError
at com.hibernate.example.util.HibernateUtil.<clinit>(HibernateUtil.java:29)
at com.hibernate.example.test.NetCanned.main(NetCanned.java:41)
Caused by: org.hibernate.MappingException: Association references unmapped class: Imdscannedconfig
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2036)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2497)
at org.hibernate.cfg.HbmBinder$SecondPass.doSecondPass(HbmBinder.java:2468)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:884)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:999)
at com.hibernate.example.util.HibernateUtil.<clinit>(HibernateUtil.java:27)
... 1 more
Exception in thread "main"

Name and version of the database you are using:
Oracle 10g

Thanks in advance for the help.

-Surya


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 19, 2005 1:12 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
in net.hbm.xml change

Code:
<one-to-many class="Imdscannedconfig"/>


to

Code:
<one-to-many class="com.hibernate.example.pos.Imdscannedconfig"/>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 19, 2005 1:21 pm 
Beginner
Beginner

Joined: Mon Aug 15, 2005 4:37 pm
Posts: 27
Location: Washington DC
Thanks Nathan.

Missed that package details.

Could be a best practice to give the package name at the top of the mapping file.


nathanmoon wrote:
in net.hbm.xml change

Code:
<one-to-many class="Imdscannedconfig"/>


to

Code:
<one-to-many class="com.hibernate.example.pos.Imdscannedconfig"/>


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