Description :
Perhaps that is not impacted by this problem because it is customary to use DTOs serve and processors to route the items on the network and therefore the specific types of hibernate are processed automatically (by processors) . In case we have no layer of DTOs serve, can be used to replace the mappers and PersistentList PersistentSet in ArrayList and HashpSet example. In short, once the objects recovered processed (without PersistentXXX) on the client, we play with, or modifies and it may be necessary to remove items from a list. And that's where the plot thickens as it may, no one really knows why, that Hibernate can not detect the deletion of an element when saving. Indeed, since we replace the list manager to hibernate when the sauce returns the cluster server side, it does not realize that there has been striking even with options such delete-orphan all-delete-orphan in the mapping. The only solution remaining is the last chance to map the list of a very different way.
A common problem :
An object Removed year from a collection mapped with cascade = "all" the goal object Was Not deleted. cascade = 'all' the cascade delete () operation from parent to child. If This Is a one-to-many association, try using cascade = "all, delete-orphan". Another Solution Is To model your child objects as composite elements (a kind of value type) Rather Than entities. Value types are gold Always PERSISTED Removed Along with Their parent entity. So you would use a Mapping for the element of a class INSTEAD mapping.
any example :
Here is the mapping of the content in item list :
Code:
set name="lst" table="element" lazy="true">
<key column="cl" not-null="true" />
<composite-element class="address here">
<parent name="tr"/>
<property name="iden" type="java.lang.Integer">
<column name="clid" />
</ Property>
<property name="comment" type="java.lang.String">
<column name="clcomment" length="254" />
</ Property>
<property name="date" type="timestamp">
<column name="cldate" />
</ Property>
</ Composite-element>
</ Set>
Instead if it is written in this way :
Code:
<list name="lst" lazy="true" cascade="persist, save-update, evict, merge, all-delete-orphan">
<key column="clid" not-null="true" />
<Voice column="clnm" />
<one-to-many class="Element" />
</ List>
Good disadvantages are obvious, it is necessary to map the list in the file mapping object and container in case the objects of the list are used in multiple objects are duplicated not very professional as they say, so better to avoid. But hey it works and objects are things within days and especially when you save the deleted object container.
Bookmarks