Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 59167 invoked from network); 9 Mar 2009 13:19:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Mar 2009 13:19:14 -0000 Received: (qmail 99707 invoked by uid 500); 9 Mar 2009 13:19:14 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 99541 invoked by uid 500); 9 Mar 2009 13:19:14 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 99522 invoked by uid 99); 9 Mar 2009 13:19:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Mar 2009 06:19:14 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Mar 2009 13:19:11 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 72694234C003 for ; Mon, 9 Mar 2009 06:18:50 -0700 (PDT) Message-ID: <253373474.1236604730454.JavaMail.jira@brutus> Date: Mon, 9 Mar 2009 06:18:50 -0700 (PDT) From: "Pinaki Poddar (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Created: (OPENJPA-968) Change in default detach() behavior for JPA 2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org Change in default detach() behavior for JPA 2.0 ----------------------------------------------- Key: OPENJPA-968 URL: https://issues.apache.org/jira/browse/OPENJPA-968 Project: OpenJPA Issue Type: Improvement Components: kernel Affects Versions: 2.0.0-M1, 2.0.0 Reporter: Pinaki Poddar Assignee: Pinaki Poddar Fix For: 2.0.0-M1, 2.0.0 JPA 2.0 specification has introduced a detach() method in EntityManager. OpenJPA already has a detach() method prior to JPA 2.0. There are several major differences between the new method introduced in JPA 2.0 spec versus existing OpenJPA detach method. 1. The method signatures are different JPA 2.0: void detach(Object entity); OpenJPA 1.x : T detach(T entity); 2. This signature difference also points to a basic difference in behavior. OpenJPA detach() creates a copy of the given input entity and returns it. While JPA 2.0 specifies in-place detach and hence returns a void. 3. The other basic difference is OpenJPA detach does not remove the input entity from the persistence context. While JPA 2.0 specifies that the input entity be removed from the context. 4. OpenJPA detach flushes a dirty instance before detaching. This implicit flush behavior can be configured but flushing is the default. 5. OpenJPA detach() provides several options on which related instances will become detached. They are 'loaded', 'fetch-group' and 'all'. With 'loaded' being the default. Whereas JPA 2.0 introduces a DEATCH cascade type and specified that the relationships that are cascaded with DETACH or ALL be traversed during detachment. It is not clear from the spec, however, a) whether an unloaded relation which has DETACH cascade will get loaded as a side-effect of detach(). b) whether a relation that is currently loaded but not cascaded for DETACH will be included in the detached graph. If answer to (a) is no and answer to (b) is yes, (which the spec does seems to suggest) then we can effectively continue with 'loaded' as the default behavior. To accommodate these differences following actions are proposed: A1. Request JPA Spec committee to change the API method in JPA 2.0 to OpenJPA detach() method signature. If that request is not met, then change OpenJPA API according to JPA 2.0 spec. It will break backward compatibility of OpenJPAEntityManager API. There seems to be no way out. A2. The default behavior will change in the following way a) the detach will be in-place b) no implict flush of dirty instances c) based on condition, how JPA 2.0 spec clarifies the DETACH cascade and loaded fields for inclusion in the detached graph, change 'loaded' default to 'cascade' default. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.