Hi Gianny,
        
Regarding JIRA Geronimo-1374

Modifying CompoundPKTransform was a very bad idea :-(. But it is required to create an Instance of the compound primary key somewhere and use it to get the GlobalIdentity as CompoundPKTransform is the transform used.  Is it  a  good idea to write another accessor specifically for this case? Then the creation of the PK instance can be moved to the accessor. But this requires the acessor to have access to the PKClass. Also this accessor will only be used for the special case that causes this error.

The set method of the accessor will be

public void set(InTxCache cache, CacheRow row, Object value) {
        GlobalIdentity id;
        Object pkObject;
        if (!pkClass.isInstance(value)) {
            try {
                pkObject = pkClass.newInstance();
                Field[] fields = pkClass.getFields();
                fields[0].set(pkObject, value);                
            } catch (IllegalArgumentException e) {
                throw new EJBException("Cannot extract global identity", e);
            } catch (IllegalAccessException e) {
                throw new EJBException("Cannot extract global identity", e);
            } catch (InstantiationException e) {
                throw new EJBException("Cannot extract global identity", e);
            }
        }
        try {
            id = transform.getGlobalIdentity(pkObject);
        } catch (IdentityTransformException e) {
            throw new EJBException("Cannot extract global identity", e);
        }
        cmpField.set(cache, row, value);
        cmrField.set(cache, row, id);
    }
      
OR
Should the existing accessor be modified to take care of this scenario?
OR
Is there some other way to resolve this issue?

Thanks
Manu

Reply via email to