Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 9613 invoked from network); 31 Jul 2008 20:48:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Jul 2008 20:48:53 -0000 Received: (qmail 86053 invoked by uid 500); 31 Jul 2008 20:48:52 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 85974 invoked by uid 500); 31 Jul 2008 20:48:51 -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 85917 invoked by uid 99); 31 Jul 2008 20:48:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Jul 2008 13:48:51 -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; Thu, 31 Jul 2008 20:48:05 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id B832A234C18E for ; Thu, 31 Jul 2008 13:48:31 -0700 (PDT) Message-ID: <849121093.1217537311753.JavaMail.jira@brutus> Date: Thu, 31 Jul 2008 13:48:31 -0700 (PDT) From: "Michael Dick (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Updated: (OPENJPA-286) Can't merge detached One-To-Many child instance. The entities were implement by an internal Hash container. In-Reply-To: <17357500.1184839984832.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-286?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Michael Dick updated OPENJPA-286: --------------------------------- Fix Version/s: 1.2.0 > Can't merge detached One-To-Many child instance. The entities were implement by an internal Hash container. > ----------------------------------------------------------------------------------------------------------- > > Key: OPENJPA-286 > URL: https://issues.apache.org/jira/browse/OPENJPA-286 > Project: OpenJPA > Issue Type: Bug > Components: jdbc > Affects Versions: 0.9.7, 1.0.0, 1.1.0 > Environment: java version "1.5.0_10" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03) > Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode, sharing) > Reporter: Gene Wu > Assignee: Pinaki Poddar > Fix For: 1.2.0 > > Attachments: hashpojo.zip > > > Maybe you know, one of the entity implementation is composite of a hash set, which stores key-value pairs. > It's a common design of Entity Bean in EJB2.x ages. Does any one use it in OpenJPA? I am using it right now, and encounter an issue in entity cascade manipulate. Here is the issue description. > Base.java : the super class of entities. > protected final Object getAttributeValue(String attributeName) { > return _values.get(attributeName); > } > protected final void setAttributeValue(String attributeName, Object value) { > _values.put(attributeName, value); > } > // To hold the {attributeName, value} pair of the value object. > private HashMap _values = new HashMap(); > C.java extends Base.java : Entity C has a set of Entity D. > public void setDs(Set ds) { > setCollection("Ds", ds); > } > @OneToMany(mappedBy = "c", fetch = FetchType.LAZY, cascade = CascadeType.ALL) > public Set getDs() { > return (Set)getAttributeValue("Ds"); > } > D.java extends Base.java as well. > The relationship between C and D is one-to-many. I use following code to reproduce the issue. > C c = em.find(C.class, 1); > logger.debug(c.getDs().size()); > D d = new D(); > d.setC(c); > c.getDs().add(d); > em.merge(c); > After commit the transaction, you will find the new D instance was not inserted into the database(there is no insert sql log as well). After you add, em.persist(c). That new instance will be added! > Meanwhile, I wrote a couple of classes, which do not use a HashSet. I got the expected result after merge is done. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.