-->
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: compile error
PostPosted: Mon Apr 24, 2006 5:59 am 
Newbie

Joined: Sat Dec 24, 2005 2:15 am
Posts: 6
Location: Melbourne
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.1.3

[b]Mapping documents:
ITEM:
<?xml......>
<doc type.......>
<hibernate-mapping>
<class name="businessObjects.Item" table="ITEM">
<id name="itemID" column="ITEMID">
<generator class="sequence" />
</id>
<property name="itemName" column="ITEMNAME" />
<property name="cost" column="COST"/>
<property name="purchaseDate" type="timestamp" column="PURCHASEDATE" />
<many-to-one name="categoryID" column="CATEGORYID" class="Category" not-null="true"/>

</class>
</hibernate-mapping>


CATEGORY:
<?xml.........>
<doctype.........>
<hibernate-mapping>
<class name="businessObjects.Category" table="CATEGORY">
<id name="catID" column="CATEGORYID">
<generator class="sequence"/>
</id>
<property name="name" column="CATNAME"/>
<property name="dateCreated" type="timestamp" column="DATECREATED"/>

</class>
</hibernate-mapping>


[b]Code between sessionFactory.openSession() and session.close(): N/A

[b]Full stack trace of any exception that occurs:


Name and version of the database you are using: Oracle8i

[b]The generated SQL (show_sql=true):


Debug level Hibernate log excerpt: log4j output:

[b]Hibernate SessionFactory failed org.hibernate.MappingException: An association from the table ITEM refers to an unmapped class: Category
Exception in thread "main" java.lang.ExceptionInInitializerError

at objectsHome.DbConnection.<clinit>(DbConnection.java:20)
at objectsHome.CategoryHome.<init>(CategoryHome.java:17)
at interfaces.ExpenseManager.something(ExpenseManager.java:141)
at interfaces.ExpenseManager.<init>(ExpenseManager.java:54)
at interfaces.ExpenseManager.main(ExpenseManager.java:135)
Caused by: org.hibernate.MappingException: An association from the table ITEM refers to an unmapped class: Category
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1134)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1052)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1168)
at objectsHome.DbConnection.<clinit>(DbConnection.java:15)

I have a many to one association in my db with Category and Item. A Category can have many items and that item only belongs in that one category. I know that the many-to-one statement in the Item.hbm.xml file is causing the problem because if I comment it out then my application compiles and runs, but I just cant see what it is with the many-to-one that causing the problem. I know my Category.hbm.xml file works and I can update, delete, save etc, so Im not understanding why when I try to compile the application hangs during the compile becuase Hibernate reports errors in the Category Mapping file.
Any help appreciated. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 24, 2006 1:37 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
have you used <hibernate-mapping package="businessObjects">

if not then in your item mapping file change
<many-to-one name="categoryID" column="CATEGORYID" class="Category" not-null="true"/>

to

<many-to-one name="categoryID" column="CATEGORYID" class="businessObjects.Category" not-null="true"/>


Top
 Profile  
 
 Post subject: compile error
PostPosted: Mon Apr 24, 2006 7:37 pm 
Newbie

Joined: Sat Dec 24, 2005 2:15 am
Posts: 6
Location: Melbourne
thanks for pointing out my missing package declaration, was much appreciated. It has done the trick.


Top
 Profile  
 
 Post subject: Re: compile error
PostPosted: Tue Apr 25, 2006 10:31 am 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
gbak1 wrote:
thanks for pointing out my missing package declaration, was much appreciated. It has done the trick.


Can you rate the post then ?


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.