I have a class representing product categories and then the class that represents the product.
The category and product has a many-to-many association.
Here is my mapping for the product category class. This is not a bidrectional relationship so my product does not have a property to store the category references it belongs to. Might this be a problem?
Code:
<set
name="elements"
table="manytomany_elements"
lazy="false"
inverse="false"
cascade="all"
sort="unsorted"
>
<key
column="relationshipID"
/>
<many-to-many
class="com.forisent.framework.productManager.store.entity.SellableProduct"
column="productID"
outer-join="auto"
/>
</set>
Here is my persistence code:
Code:
public Object persist(Object obj) throws PersistenceException{
Session session = null;
log.info("Persisting object: " + obj.getClass().toString());
try{
session = getSession();
try{
session.saveOrUpdate(obj);
}catch(HibernateException e){
log.error("Rolling Back Persist Operation");
}
session.flush();
}catch(HibernateException e){
throw new PersistenceException(e.getMessage(), e);
}finally{
try{
closeSession();
}catch(HibernateException e){
throw new PersistenceException(e.getMessage(), e);
}
}
return obj;
}
When I try to persist the relationship, I get this error:
Code:
com.forisent.framework.common.exception.PersistenceException: Could not execute JDBC batch update
The data is being persisted but I get all these exceptions for each time I try to persist the many-to-many relationship.
Any ideas what I have done wrong?