you could use a proxied reference. the scenarios you mentioned are quite difficult to distinguish.
hth jakob
Avril Kotzen wrote:
I am using OJB 1.0.rc4 Persistence Broker API. I am not
using anonymous keys. Under a certain scenario, an existing
1:1 association is being lost on an update.
Here is the scenario. Assume object A and B have a 1:1 relationship. Object A has an attribute b of type B and an attribute bId which should hold the associated primary key of B. Assume both A and B have been previously persisted and that bId is primed. Let A be retrieved without cascading B. Thus attribute b is null but bId has a value. Now A is updated. On this update bId is set to null. This breaks the association between A and B.
The key is set to null in PersistenceBrokerImpl.assertFkAssignment(Object obj,
Object ref,ObjectReferenceDescriptor rds) ...
if (ref == null) {
refPkValues = new Object[objFkFields.length];
...
for (int i = 0; i < objFkFields.length; i++) {
objFkFields[i].getPersistentField().set(
realObj,refPkValues[i]);
}
While I can see a case of needing to set the associated key to null if the reference is null, I think the above scenario also presents a case where this is not the desired result.
Is there something I should be doing to prevent the association from being broken if the reference attribute is null, but the key attribute is not.
Thanks for your help
Avril
___________________________________________
Look Good, Feel Good www.healthiest.co.za
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
