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.