Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 14945 invoked from network); 20 Mar 2007 23:09:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Mar 2007 23:09:48 -0000 Received: (qmail 40966 invoked by uid 500); 20 Mar 2007 23:09:56 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 40936 invoked by uid 500); 20 Mar 2007 23:09:56 -0000 Mailing-List: contact open-jpa-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: open-jpa-dev@incubator.apache.org Delivered-To: mailing list open-jpa-dev@incubator.apache.org Received: (qmail 40927 invoked by uid 99); 20 Mar 2007 23:09:56 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Mar 2007 16:09:56 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of mprudhomapache@gmail.com designates 66.249.82.237 as permitted sender) Received: from [66.249.82.237] (HELO wx-out-0506.google.com) (66.249.82.237) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Mar 2007 16:09:45 -0700 Received: by wx-out-0506.google.com with SMTP id i26so60158wxd for ; Tue, 20 Mar 2007 16:09:24 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer:sender; b=odujazFqDcbDkfWr+ZhlQwlauWTdt/1NvFum+YxFaMlkbDxod4YvwJvMs13WIlgzbY4PprrA7FijelMoBnyKHhxCXhplNMgiJPfltTGOhBAaJ6YpsCkYmToVR2+O3xkpiYR3nBMv5gKxGSG8pisDBtsdnQPcLBy2gsnRfC2PT1I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer:sender; b=UaWLLcwfnJXzwS3qbQivR5Ni0AW5MgJDCT6iWqfY6+q89+/Z4ulJTwcAVu2KJLFufNxwJZig5t/F0FiYNdTdedqqFjBeH+308vDNmtyq3De4qfsgzdTeIeOPphqW4FcQJK5BgFGtdZ2++PFjT/v/kXEHtCSA2Rt5X9ivoLJy/gA= Received: by 10.90.118.12 with SMTP id q12mr1656295agc.1174432164444; Tue, 20 Mar 2007 16:09:24 -0700 (PDT) Received: from ?192.168.15.101? ( [66.248.222.34]) by mx.google.com with ESMTP id 36sm1631891aga.2007.03.20.16.09.23; Tue, 20 Mar 2007 16:09:24 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.3) In-Reply-To: <460067EB.8050403@sun.com> References: <45F9DE3C.5020202@sun.com> <49F3A300-9A8C-433F-99D3-845F41C2E6F8@apache.org> <460067EB.8050403@sun.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Marc Prud'hommeaux Subject: Re: Using DDL generation in a Java EE environment? Date: Tue, 20 Mar 2007 16:09:10 -0700 To: open-jpa-dev@incubator.apache.org X-Mailer: Apple Mail (2.752.3) Sender: Marc Prud'hommeaux X-Virus-Checked: Checked by ClamAV on apache.org Marina- On Mar 20, 2007, at 4:02 PM, Marina Vatkina wrote: > Marc, > > Thanks for the pointers. Can you please answer the following set of > questions? > > 1. The doc requires that "In order to enable automatic runtime > mapping, you must first list all your persistent classes". Is this > true for EE case also? Yes. People usually list them all in the tags in the persistence.xml file. > 2. Section "1.2.Generating DDL SQL" talks about .sql files, but > what I am looking for are "jdbc" files, i.e. files with the lines > that can be used directly as java.sql statements to be executed > against database. The output should be sufficient. Try it out and see if the format is something you can use. > 3. Is there a document that describes all possible values for the > "openjpa.jdbc.SynchronizeMappings" property? Unfortunately, no. Basically, the setting of the "SynchronizeMappings" property will be of the form "action (Bean1=value1,Bean2=value2)", where the "bean" values are those listed in org.apache.openjpa.jdbc.meta.MappingTool (whose javadoc you can see http://incubator.apache.org/openjpa/docs/latest/javadoc/org/ apache/openjpa/jdbc/meta/MappingTool.html ). > thank you, > -marina > > Marc Prud'hommeaux wrote: >> Marina- >> On Mar 15, 2007, at 5:01 PM, Marina Vatkina wrote: >>> Hi, >>> >>> I am part of the GlassFish persistence team and was wondering >>> how does OpenJPA support JPA auto DDL generation (we call it >>> "java2db") in a Java EE application server. >>> >>> Our application server supports java2db via creating two sets of >>> files for each PU: a ...dropDDL.jdbc and a ...createDDL.jdbc >>> file on deploy (i.e. before the application is actually loaded >>> into the container) and then executing 'create' file as the last >>> step in deployment, and 'drop' file on undeploy or the 1st step >>> in redeploy. This allows us to drop tables created by the >>> previous deploy operation. >>> >>> This approach is done for both, the CMP and the default JPA >>> provider. It would be nice to add java2db support for OpenJPA as >>> well, and I'm wondering if we need to do anything special, or >>> it'll all work just by itself? >> We do have support for runtime creation of the schema via the >> "openjpa.jdbc.SynchronizeMappings" property. It is described at: >> http://incubator.apache.org/openjpa/docs/latest/manual/ >> manual.html#ref_guide_mapping_synch >> The property can be configured to run the mappingtool (also >> described in the documentation) at runtime against all the >> registered persistent classes. >>> Here are my 1st set of questions: >>> >>> 1. Which API would trigger the process, assuming the correct >>> values are specified in the persistence.xml file? Is it: >>> a) .createContainerEntityManagerFactory(...)? or >>> b) the 1st call to emf.createEntityManager() in this VM? >>> c) something else? >> b >>> 2. How would a user drop the tables in such environment? >> I don't think it can be used to automatically drop then create >> tables. The "mappingtool" can be executed manually twice, the >> first time to drop all the tables, and the second time to re- >> create them, but I don't think it can be automatically done at >> runtime with the "SynchronizeMappings" property. >>> 3. If the answer to either 1a or 1b is yes, how does the code >>> distinguish between the server startup time and the application >>> being loaded for the 1st time? >> That is one of the reasons why we think it would be inadvisable >> to automatically drop tables at runtime :) >>> 4. Is there a mode that allows creating a file with the jdbc >>> statements to create or drop the tables and constraints? >> Yes. See: >> http://incubator.apache.org/openjpa/docs/latest/manual/ >> manual.html#ref_guide_ddl_examples >>> thank you, >>> -marina >>> >