Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 72038 invoked from network); 8 Jul 2010 11:21:24 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Jul 2010 11:21:24 -0000 Received: (qmail 55177 invoked by uid 500); 8 Jul 2010 11:21:24 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 54941 invoked by uid 500); 8 Jul 2010 11:21:21 -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 54933 invoked by uid 99); 8 Jul 2010 11:21:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jul 2010 11:21:20 +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 (nike.apache.org: domain of matero@gmail.com designates 209.85.160.43 as permitted sender) Received: from [209.85.160.43] (HELO mail-pw0-f43.google.com) (209.85.160.43) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jul 2010 11:21:13 +0000 Received: by pwj6 with SMTP id 6so301250pwj.16 for ; Thu, 08 Jul 2010 04:20:51 -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=9HGIOYs2B/mq82UxOI9/1r9dRsAf+ro32l/iS83bdf4=; b=ln4Zqe14t/q1LRusfeovciptZuK1O2uQdMnv9QQErupg6VkGM/1tBJ1Qxe+D5Gg/W2 CiAgpnlVcFnzTD7feMQl2AoZ2xQTiWaPcLajaCRMeBrwKNPdhtCrf8TB30vTjqt7wjdg VgiEOOuHsXmBrHewU1u7dWbcLx2+4Xjl/ZMFs= 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=d/hk65WjgFwSVrZUbIJ9bk67X1ptmWaBy8oDO4KxhF73Q8f9DI4DLnWyle1oa4pCrP n/hEkhBONSlmJeRgTnqCyzS033P0P9x6irRm+WQuZRyDrDHl2nIinyiAo9+ZcWU3f+2S dvI/7+N53lwrn3GvBeLV7LoC+C5PmjauL2/A8= MIME-Version: 1.0 Received: by 10.142.188.13 with SMTP id l13mr9473661wff.98.1278588051434; Thu, 08 Jul 2010 04:20:51 -0700 (PDT) Received: by 10.142.212.16 with HTTP; Thu, 8 Jul 2010 04:20:51 -0700 (PDT) In-Reply-To: References: <201007062301.21865.matero@gmail.com> <74379189-6B62-4192-B502-6CE0C85612A0@objectstyle.org> Date: Thu, 8 Jul 2010 08:20:51 -0300 Message-ID: Subject: Re: Re: Mapping views with modeller From: =?UTF-8?Q?Juan_Jos=C3=A9_Gil?= To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=000e0cd28d389eac9b048ade7a5a X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd28d389eac9b048ade7a5a Content-Type: text/plain; charset=UTF-8 Gary, thanks for your aclarations, they cleared mi mind... after I let my questions out I find some of the answers (like the read-only objects) myself... I should learn to do less questions and more reading :( I expect to return something to cayenne some day :) regards Juanjo 2010/7/7 Gary Jarrel > On Wed, Jul 7, 2010 at 11:48 PM, matero wrote: > > Thanks Andrus. > > > > So, to map a view, I need to create it on my DB, then import it with the > > modeler and then map it. > > Or I should create the DbEntity as a normal one (putting all its > attributes as > > read-only) ? > > If you have a view in the database you can reverse engineer it into > the Cayenne Modeler and the modeler will create both the DB and the > OBJ entities for you. Alternatively you can do the whole process > manually by creating a db entity having the same name as your view and > then map each attribute in the modeler to the respective attribute in > the view. Then you create your object entity and map it to the > database entity via the Table/View option and then you can sync the > object entity so that it picks up all the fields from the view. > > > Is it possible from the meta-model maintained by cayenne determine if an > > ObjEntity maps a table or a view? this could be used to define which > class > > extend in the velocity template avoiding update / insert operations. > > If it is not possible, then I should used some kind of convention on > > tables/views names but I prefer to use the cayenne meta-model. > > Not all views are read only, we commonly use views to update things in > the database (but not all database would support updating through > views) however any object entity can me made a "Read Only" entity by > specifying that it's "Read Only" in the modeler. And in this instance > the class generator (which uses velocity templates) will not generate > the setter methods. > > > Finally, is there a way to tell the modeler "don't try to assign a PK to > this > > kind of entity" (in hibernate there is a "assigned id" strategy whih does > this). > > We tend to include some unique identifier in any given view that we > use. When we take this approach we set the "PK Generation Strategy" to > "Database Generated" (in the DB entity) and let the database handle > the rest. > > Otherwise (and I could be wrong here) you can leave out specifying the > Primary Key in the DB entity and leave the "PK Generation Strategy" at > default hence nothing would be generated since there is no Primary > Key. However I don't think this is such a good idea at all. > > Hope this helps. > > gary > --000e0cd28d389eac9b048ade7a5a--