Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 81883 invoked from network); 2 Nov 2010 18:33:41 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Nov 2010 18:33:41 -0000 Received: (qmail 85654 invoked by uid 500); 2 Nov 2010 18:34:12 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 85638 invoked by uid 500); 2 Nov 2010 18:34:12 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 85630 invoked by uid 99); 2 Nov 2010 18:34:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Nov 2010 18:34:12 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of caden.whitaker@gmail.com designates 74.125.82.47 as permitted sender) Received: from [74.125.82.47] (HELO mail-ww0-f47.google.com) (74.125.82.47) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Nov 2010 18:34:06 +0000 Received: by wwf26 with SMTP id 26so7332853wwf.28 for ; Tue, 02 Nov 2010 11:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=dJQ9sPRdKqZTlJT+Jow/LVbxtY0x9PppyddT+b+9SeQ=; b=EgMPk10YDt9JYr2eIfWBTzIHPpuFiXJ2ZQkzSDOPsHXvpVUvoYVqBUbcmAyv71d8yU 948xViC9kvynfQjkLvffrjkynjeIsaIr6tdAhPUAr38x1wpgV95LJy0w9K/W7L69zNbI sKpywDjVHG1k/Ec+Ye5vuGjQibMPion0kr1Fo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=N/3JwztUMgdQlAWwguZzniHtOs0n3RwDpGtU2N0BI9AgjEuNpEjmFuwmDYgq7heyrK wDW3KmIUYAH2v/mewY8fZbP0Uo2Uey1sqRI2ihT5HUZKhJva11rDmwZNstO2/lFVYKaA 0kziA7SqkSooIlVreyh7v7ZawrJYwDZKhTQ1Y= MIME-Version: 1.0 Received: by 10.227.63.15 with SMTP id z15mr4426708wbh.214.1288722824551; Tue, 02 Nov 2010 11:33:44 -0700 (PDT) Received: by 10.227.3.18 with HTTP; Tue, 2 Nov 2010 11:33:44 -0700 (PDT) In-Reply-To: References: Date: Tue, 2 Nov 2010 13:33:44 -0500 Message-ID: Subject: Re: DataMap.loadDataMap existing ObjectContext? From: caden whitaker To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=20cf300258522bde680494162ab0 --20cf300258522bde680494162ab0 Content-Type: text/plain; charset=ISO-8859-1 Got it working, here is the code, note this code can probably be reduced, but it at least did the job DataDomain dd = Configuration.getSharedConfiguration().getDomain(); MapLoader ml = new MapLoader(); DataMap dataMap = ml.loadDataMap(new InputSource(new FileInputStream("C:\\eclipse_cayenne\\tutorial\\src\\main\\resources\\HelloWorld2Map.map.xml"))); // Add the shared map to the target data domain dd.addMap(dataMap); // Add the shared map to the data node Collection nodes = dd.getDataNodes(); if (nodes.size() != 1) { System.out.println("Expected only one DataNode for DataDomain '" + "" + "' -- this DataDomain is not usable."); return; } Iterator dataNodeIterator = nodes.iterator(); // We are only getting one, though ... while (dataNodeIterator.hasNext()) { DataNode node = (DataNode) dataNodeIterator.next(); node.addDataMap(dataMap); } ObjectContext context = dd.createDataContext(); Artist picasso = context.newObject(Artist.class); picasso.setName("Pablo Picasso"); Painting girl = context.newObject(Painting.class); girl.setName("Girl Reading at a Table"); girl.setArtist(picasso); Painting stein = context.newObject(Painting.class); stein.setName("Gertrude Stein"); stein.setArtist(picasso); context.commitChanges(); --20cf300258522bde680494162ab0--