I think there are 2 issues here:
1 - whether or not to the cascade compatibility option is needed
2 - whether or not the options loaded, fetch-group, and all are handled
Although these may be interrelated, let's discuss them individually at first.
For the cascade compatibility option question, we first have to agree on what the old behavior does. I have created a simple test case for this, with the new patch cascadeTestPatch.txt. The cascade relationship of the entities is:
Entity1 to Entity2 - ALL
Entity2 to Entity3 - PERSIST only
When you run this test on an openjpa version without my changes, you'll see that all entities are detached when detach(e1) is run. So, it automatically cascades. (Note: I know this is with all entities loaded. Again, I'll address that later.)
Second, what would the spec expect in this scenario with the new clear(Object) option. Here's what the spec says in section 3.2.6:
The semantics of the clear operation, applied to an entity X are as follows:
•If X is a managed entity, the clear operation causes it to become detached. The clear operation is cascaded to entities referenced by X, if the relationships from X to these other entities is annotated with the cascade=CLEAR or cascade=ALL annotation element value. Entities which previously referenced X will continue to reference X.
•If X is a new or detached entity, it is ignored by the clear operation.
•If X is a removed entity, the clear operation is cascaded to entities referenced by X, if the relationships
from X to these other entities is annotated with the cascade=CLEAR or cascade=
ALL annotation element value. Entities which previously referenced X will continue to reference X. Portable applications should not pass removed entities
It seems to me that bullet 1 implies that the cascade should ONLY occur if cascade=CLEAR or or cascade=ALL. Therefore, in my test case, Entity3 should NOT be detached. So, that needs to be the default behavior. In order to provide backward compatibility for the pre-existing detach behavior, we need to provide the cascadeWithDetach compatibility option.
In order to address item 2 above, I need to write some more test cases. (Admittedly I should have done that.) I'll address that in a subsequent post.