geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Manu T George (JIRA)" <>
Subject [jira] Updated: (GERONIMO-1374) Open EJB does not allow the setting of a ForiegnKey that is involved in a CMR relationship
Date Thu, 12 Jan 2006 12:17:23 GMT
     [ ]

Manu T George updated GERONIMO-1374:

    Attachment: CMPContainerBuilder.patch

This patch will fix this issue as well as the issue of multiple CMRFields in the primary key
as well as  the issue mentioned below

 Consider a Bean A and a bean B in a one to many CMR relationship
            Here A has 2 fields in the PK say a1 and a2
                    B has b1 fka1 and fka2 as the pk where fka1 and fka2 are the foreign keys
corressponding to the a1 and a2 of A.
            In the ejbCreate of B when we set fka1 and fka2 won't OpenEJB throw an error saying
that they are readonly fields. This will happen even after  implementing the logic for the
special case where the CompoundPK has 1 field.  Is this scenario a valid scenario? If so can
we change the check in createCMPFieldAccessors to check for primary key and allow write access
to CMR fields if they are parts of Primary Keys? What should be the correct behaviour?

The fix for the first patch is as suggested by Gianny. The CMRCompoundAccessor is used whose
get Method has been changed to

    public Object get(InTxCache cache, CacheRow cacheRow) {
        GlobalIdentity globalId = (GlobalIdentity) cmrField.get(cache, cacheRow);
        try {
            Field[] fields = pkClass.getFields();            
            return globalId == null ? 
                    null : fields[0].get(transform.getDomainIdentity(globalId));
        } catch (IdentityTransformException e) {
            throw new EJBException("Unable to create proxy for id " + globalId, e);
        } catch (IllegalArgumentException e) {
            throw new EJBException("Cannot extract value from domain identity", e);
        } catch (IllegalAccessException e) {
            throw new EJBException("Cannot extract value from domain identity", e);
This accessor is used only in the case of Single Field Compound PK
For the second issue another Accessor  CMRMultiplePKAsFKAccessor is used.
This accessor is used only if the cmp field involved in a cmr relationship is a part of the
primary key.
Since they are multiple cmp fields involved in cmr the global identity is set only after the
last CMR field for which the accessor  CMRMultiplePKAsFKAccessor is used.  For other CMPFields
involved in CMR we do not use this accessor as we need to set the GlobalIdentity only once.
The slot numbers are passed to set the different fields in the CompoundPrimaryKey as during
set method only 1 field is got but we need other fields to extract the identity.

> Open EJB does not allow the setting of a ForiegnKey that is involved in a CMR relationship
> ------------------------------------------------------------------------------------------
>          Key: GERONIMO-1374
>          URL:
>      Project: Geronimo
>         Type: Bug
>   Components: OpenEJB
>     Versions: 1.0-M5
>  Environment: JDK 1.4.2_09 WindowsXP
>     Reporter: Manu T George
>     Assignee: Gianny Damour
>      Fix For: 1.0.1
>  Attachments: CMPContainerBuilder.patch, CMPContainerBuilder.patch,,, CompoundPKTransform.patch
> I have two CMPs with a 1:n relationship.
> CMP1 -  Order - PK = OrderPK which has a single field orderId
> CMP2  - OrderItem = OrderItemPk which has 2 fields InventoryId and order_orderId
> OrderId and order_orderId are mapped
> When i do a setOrder_orderId in the ejbCreate of OrderItem geronimo gives an error during
runtime saying cannot set read only field.
> When i don't set it geronimo says partial null key . In this case I set the cmr field
in the ejbPostCreate method
>  org.tranql.identity.UndefinedIdentityException: Partial null key
>     at org.tranql.identity.DerivedIdentity.defineIdentity(
>     at org.openejb.entity.cmp.CMPCreateMethod.execute(
>     at org.openejb.dispatch.DispatchInterceptor.invoke(
>     at
>     at org.openejb.ConnectionTrackingInterceptor.invoke(
>     at org.openejb.entity.EntityInstanceInterceptor.invoke(
>     at org.openejb.entity.cmp.InTxCacheInterceptor.invoke(
>     at org.openejb.transaction.ContainerPolicy$TxRequired.invoke(

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message