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
|