Hello,
I have read the docs,faqs and more and still can't figure it out.
I'm using Hibernate 2.1 with mySQL 4.
My object model is using many-to-many associations for holding lists of objects.
Part of my mapping files is as follows:
A RuleBO class holds a list of actions.
The list class is ActionListBO and the action class is ActionBO.
I get a new transient RuleBO instance from the client and try to update it, so I call the session.saveOrUpdate(rule) method.
The problem:
If the client adds some actions, they are persisted and saved.
If the client deletes some actions, they are only deleted from the list item table but the actual actions aren't deleted.
Implementing it myself means that I have to compare the transient instance with the persistent instance and compute the deleted items, which is quite complicted.
Any help would be appreciated.
Eyal.
Code:
/**
* A list of actions.
* @hibernate.class table="ActionList"
*/
public class ActionListBO extends ListBO {
/**
* @return m_listItems
* @hibernate.list
* table="ActionListItems"
* lazy="true"
* cascade="all"
* @hibernate.collection-key
* column="ListId"
* @hibernate.collection-index
* column="I"
* @hibernate.collection-many-to-many
* column="ActionId"
* class="com.mercado.s2002.businessmng.objects.rules.ActionBO"
*/
public List getList() {
return m_listItems;
}
/**
* @param m_listItems
*/
public void setList(List list) {
m_listItems = list;
}
Code:
/**
*
* @hibernate.class
* table="Action"
* lazy="com.mercado.s2002.businessmng.objects.rules.ActionBO"
*/
public class ActionBO {
// the object unique identifier
private ID m_id;
// the object persistent version
private int m_version;
/**
* Ctor.
*/
public ActionBO () {
}
/**
* Get the object id
* @return m_id
*/
public ID getId () {
return m_id;
}
/**
* Set the objcte id
* @param id
*/
public void setId (ID id) {
m_id = id;
}
/**
* @return m_version
* @hibernate.version
*/
public int getVersion () {
return m_version;
}
/**
* @param version persistent version
*/
public void setVersion (int version) {
m_version = version;
}