Thanks for the quick investigation. That has indeed fixed that issue. However there appear to be two more.
First, as we are dealing with maps, the "equals" and "hashcode" methods on the key object have to be overridden, so that "containsKey" and "get" methods work correctly. The issue with this is, when "find" is called, the object is being lazy loaded. So if the "equals" or "hashcode" method use more than the database id for generation or comparison, it all fails horribly. Have a look at the output from the second junit test, you will see heaps of calls like:
AttributeName EQUALS method called for <attributename name="null" values="" id="11"/> against: <attributename name="null" values="" id="10"/>
where the equals method has been called, but the attributename appears to have been lazy loaded.
For the purposes of continuing, I have set my "equals" method in attribute name to look only at the database id.
Second issue. The docs at: http://www.objectdb.com/api/java/jpa/OneToMany state: "When the collection is a java.util.Map, the cascade element and the orphanRemoval element apply to the map value." This appears to mean that if I have cascade=CascadeType.ALL on a OneToMany map, then the cascade ONLY applies to the values, NOT to the key. This means all keys MUST be created prior to trying to persist the map.
So I set the annotation on Holder.java at line 92 to have CascadeType.ALL. The test created the AttributeNames via the dao prior to trying to persist. The list of OtherObject is NOT persisted prior to the call. When I call persist, it fails with exception about trying to reuse a primary key for AttributeName. So I removed the CascadeType.All from Holder and persisted the OtherObjects prior to calling update on Holder and then it all works. However that then means any sub parts of OtherObjects (ie the Map<string,String>) don't get updated when they are changed (this is what the unit test is setup testing at the mo).
To reproduce the error, try replacing the annotation at line 92 in Holder.java, and removing the persisting of OtherObject in the unit test (lines 136-139 for ExampleTest.java).
I have attached the updated Maven project. Please let me know if I have missed something, or miss read the docs