Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 61912 invoked from network); 10 Jul 2005 05:45:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 Jul 2005 05:45:37 -0000 Received: (qmail 35799 invoked by uid 500); 10 Jul 2005 05:45:25 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 35764 invoked by uid 500); 10 Jul 2005 05:45:25 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 35745 invoked by uid 99); 10 Jul 2005 05:45:25 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=SPF_FAIL X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Jul 2005 22:45:13 -0700 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 1087A16 for ; Sun, 10 Jul 2005 07:45:10 +0200 (CEST) Message-ID: <99248317.1120974310066.JavaMail.jira@ajax.apache.org> Date: Sun, 10 Jul 2005 07:45:10 +0200 (CEST) From: "Gianny Damour (JIRA)" To: dev@geronimo.apache.org Subject: [jira] Assigned: (GERONIMO-675) CMR / CMP Fields should not be read-only In-Reply-To: <1546025948.1118759567618.JavaMail.jira@ajax.apache.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/GERONIMO-675?page=all ] Gianny Damour reassigned GERONIMO-675: -------------------------------------- Assign To: Gianny Damour > CMR / CMP Fields should not be read-only > ---------------------------------------- > > Key: GERONIMO-675 > URL: http://issues.apache.org/jira/browse/GERONIMO-675 > Project: Geronimo > Type: Bug > Components: OpenEJB > Versions: 1.0-M4 > Environment: Windows > Reporter: Matt Hogstrom > Assignee: Gianny Damour > > > On 14/06/2005 12:42 PM, Matt Hogstrom wrote: > > > >>I have a typical bean sequence where there is an Order and a number of Order Lines. (1 ... many) The OrderEnt is created from a Session bean coincidentally named OrderSes. The OrderEnt then in ejbPostCreate creates the appropriate OrderLines. Here is the code from OrderEnt: > >> > >> public void ejbPostCreate(OrderDataBean odb, boolean deferred) > >> throws CreateException { > >> > >> > > > > > >>Depending on the situation one of the above orderLineHome.create methods is invoked. So far, so good. > >> > >>In the OrderLineEnt.create method things go a bit wrong. Here is the stack trace: > >> > >>Caused by: javax.ejb.EJBException: cmp-field [orderId] is read-only. > >> at org.tranql.ejb.ReadOnlyCMPFieldAccessor.set(ReadOnlyCMPFieldAccessor.java:44) > >> at org.openejb.entity.cmp.CMPSetter.invokeInstance(CMPSetter.java:74) > >> at org.openejb.entity.cmp.CMPMethodInterceptor.intercept(CMPMethodInterceptor.java:75) > >> > >> > > Based on this stack-trace, I confirm that the CMP field orderId is > > mapped to a foreign key. > > > >>Here is the ejbCreate method that is failing > >> > >> public OrderLineEntPK ejbCreate(int id, Integer orderId, String itemId, int quantity, BigDecimal totalValue, > >> int olineStatus, java.sql.Date shipDate, BigDecimal msrp) throws CreateException { > >> > >> if( debugging ) > >> debug.println(3, "ejbCreate of ol_id = " + id + ", o_id = " > >> + orderId); > >> > >> setId(id); > >> setOrderId(orderId); <==================== This is the line that is failing. > >> setItemId(itemId); > >> setQuantity(quantity); > >> setTotalValue(totalValue.setScale(2, BigDecimal.ROUND_UP)); > >> setOlineStatus(olineStatus); > >> > >> > >> > >>OrderId is the FK to the Order. > >> > >> > > Fields mapped to foreign key columns are read-only. They are read-only > > for the following reason: > > Let's assume that: > > * we have one existing line item lineItemEntity; > > * lineItemEntity is already related to an order orderEntity; > > * orderEntity is related to two line items, lineItemEntity (as expected) > > and lineItemEntity2; > > * we want to relate lineItemEntity to a new order orderEntity2; > > * orderEntity2 is related to zero line items; and > > * line item defines a CMR field order to set its related order. > > > > In this specific scenario, if we set the CMR field order of > > lineItemEntity to orderEntity2, then: > > * orderEntity2 is now related to the line item lineItemEntity; and > > * orderEntity is now related to only one line item lineItemEntity2. > > > > In this same scenario, if we set the CMP field orderId of lineItemEntity > > to the primary key of orderEntity2, then I am not sure of what the > > result should be. Indeed, it is a CMP field and no specfic semantic is > > attached to it. > > > > To some extent, I am not sure that we should allow developers to update > > relationships via a direct update to the underlying foreign key columns. > > We could implement a fix to have a CMR semantic for CMP fields mapped to > > foreign ley columns; yet it does not sound good. Having said that, I do > > not have a strong opinion and I am happy to support such a scenario, if > > we need to. > > > > Also, it is worth to notice that such a potential fix will only be able > > to handle CMP having simple primary keys. CMP having compound primary > > keys will still have a read-only approach. > > > >>First question is the deployment right for this scenario? If it is, then I think that the container is not acting correctly. This code runs on WebLogic, Sun One, WebSphere, etc. > >> > >> > > Do you know if they properly support such scenarii (the CMP field must > > have a CMR semantic)? Also, do you know if they do not allow such > > scenarii in the case of compound PK CMP? > > > > Thanks, > > Gianny -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira