-->
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: Many to Many on same table
PostPosted: Fri Jun 10, 2005 2:22 pm 
Newbie

Joined: Fri Jun 10, 2005 1:52 pm
Posts: 9
Hi,
I am having problems doing a many2many mapping on the same table.
There is a PRODUCT table and a DEPENDENCY table. The relationship, each product can have other products as its dependents and vice versa.

DB looks like:

PRODUCT
________

product_id

DEPENDENCY
___________

id
parent_product_id
dependent_product_id

=========================

parent_product_id and dependent_product_id are FK to PRODUCT.product_id


Gettin errors...details as follows:
Please help (with the mapping file)!

Hibernate version: 3

Mapping documents:

<class name="Product" table="PRODUCT">
<id name="productID" type="java.lang.Long" column="product_id">
<generator class="native"/>
</id>
<set name="dependentProducts" table="DEPENDENCY" cascade="save-update" inverse="true">
<key column="dependent_product_id"/>
<many-to-many class="Product" column="product_id"/>
</set>

<set name="parentProducts" table="DEPENDENCY">
<key column="parent_product_id"/>
<many-to-many class="Product" column="product_id"/>
</set>
</class>




Full stack trace of any exception that occurs:
32047 [main] ERROR util.JDBCExceptionReporter - Unknown column 'product_id' in 'field list'
32047 [main] ERROR def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
.
.
.
.
(stack trace till main....)


Name and version of the database you are using: MySQL 4.1


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.