Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 47343 invoked from network); 29 Sep 2009 16:37:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Sep 2009 16:37:45 -0000 Received: (qmail 99504 invoked by uid 500); 29 Sep 2009 16:37:44 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 99477 invoked by uid 500); 29 Sep 2009 16:37:44 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 99467 invoked by uid 99); 29 Sep 2009 16:37:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Sep 2009 16:37:44 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [91.121.27.207] (HELO 16.mail-out.ovh.net) (91.121.27.207) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 29 Sep 2009 16:37:33 +0000 Received: (qmail 24112 invoked by uid 503); 29 Sep 2009 16:15:40 -0000 Received: from 42.mail-out.ovh.net (213.251.189.42) by 16.mail-out.ovh.net with SMTP; 29 Sep 2009 16:15:40 -0000 Received: (qmail 23624 invoked by uid 503); 29 Sep 2009 12:04:07 -0000 Received: from b7.ovh.net (HELO mail421.ha.ovh.net) (213.186.33.57) by 42.mail-out.ovh.net with SMTP; 29 Sep 2009 12:04:07 -0000 Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 29 Sep 2009 12:03:50 -0000 Received: from mol92-1-82-67-218-223.fbx.proxad.net (HELO Hydrogen.novlog.net) (j-b.briaud%novlog.com@82.67.218.223) by ns0.ovh.net with SMTP; 29 Sep 2009 12:03:48 -0000 Message-Id: <0FB0238A-712D-4DD7-8B99-56D84C0DF4C7@novlog.com> From: Jean-Baptiste BRIAUD -- Novlog To: users@openjpa.apache.org In-Reply-To: <1254163758818-3731174.post@n2.nabble.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: Generating DDL without connecting to Database (OpenJPA 1.2.1) Date: Tue, 29 Sep 2009 14:03:37 +0200 References: <1254163758818-3731174.post@n2.nabble.com> X-Mailer: Apple Mail (2.936) X-Ovh-Tracer-Id: 17844387625395019814 X-Ovh-Remote: 82.67.218.223 (mol92-1-82-67-218-223.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|U 0.5/N X-Virus-Checked: Checked by ClamAV on apache.org You might gain some reusability and better Ant code by using macrodef. http://ant.apache.org/manual/CoreTasks/macrodef.html Here is the macrodef I'm using for example : On Sep 28, 2009, at 20:49 , Marc.Boudreau wrote: > > I had been struggling with this feature for a few days and finally > figured it > out. Since none of the posts that I found in my many searches led > me to the > resolution, I thought I would post what I was doing wrong and what I > did to > fix it. > > Our project is required to generate the SQL scripts to create the > schema for > our 6 supported database vendors at build time. So I edited the ANT > script > used to build the project and added the following target: > > > classname="org.apache.openjpa.jdbc.ant.MappingToolTask" > classpathref="classpath.openjpa"/> > > sqlFile="${basedir}/schema/${vendor}/create.sql"> > propertiesFile="META-INF/persistence.xml"/> > > > > > > > > I then added antcalls to my new target like this: > > > > ... and so forth for the 5 other vendors. > > After careful scrutiny of the documentation of the options/flags for > the > Mapping Tool > (http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/docs/manual/manual.html#ref_guide_mapping_mappingtool > ), > I realized that "buildSchema" is the default value for the action > attribute, > so I omitted it. And then looking at the documentation of the > options for > the Schema Tool > (http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/docs/manual/manual.html#ref_guide_schema_schematool > ) > I saw that "add" is the default action, but what I need is "build", > so I > added the schemaAction attribute and set its value to "build". > > At this point I thought I had it for sure. But, the tool still > tried to > connect to the database but failed because I didn't specify a > ConnectionDriverName (or any other connection details for that > matter). > > Finally, I saw that there is an argument named "readSchema". This > is a > boolean flag and the documentation doesn't say which is the default > value. > But after I set this option to false in my ANT script, the tool > succeeded. > This is the final ANT target: > > > classname="org.apache.openjpa.jdbc.ant.MappingToolTask" > classpathref="classpath.openjpa"/> > > sqlFile="${basedir}/schema/${vendor}/create.sql" readSchema="false"> > propertiesFile="META-INF/persistence.xml"/> > > > > > > > > > Marc Boudreau > -- > View this message in context: http://n2.nabble.com/Generating-DDL-without-connecting-to-Database-OpenJPA-1-2-1-tp3731174p3731174.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. >