openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phani Madgula" <phanibalaji.madg...@gmail.com>
Subject Re: Can somebody tell me how to generate DDLs
Date Wed, 17 Dec 2008 12:04:07 GMT
Thanks for info...I am able to generate the DDLs into a file. The
MappingTool requires database connection though.

Thanks
Phani

On 12/17/08, Michael Dick <michael.d.dick@gmail.com> wrote:
> Hi all,
>
> If a connection to the database is not available (or desired) you can try
> something like this.
>
> Assumptions :
>  1.  target/classes contains your compiled classes
>  2.  target/classes/META-INF/persistence.xml exists and includes a list of
> your entities
>  3.  ${OPENJPA_LOC} contains openjpa.jar
>  4.  ${OPENJPA_LOC}/lib includes the dependencies from our binary archive
>  5.  The example uses derby, you can use db2, oracle or any of the
> DBDictionary classes included with OpenJPA
>
> $ export CLASSPATH=target/classes:${OPENJPA_LOC}/openjpa.jar
> $ java -cp ${CLASSPATH} -Djava.ext.dirs=${OPENJPA_LOC}/lib
> org.apache.openjpa.jdbc.meta.MappingTool -sql temp.ddl -sa build
> -DBDictionary derby
>
> This will generate temp.ddl with the assumption that none of the tables
> exist.
>
> You can do something similar in ant with syntax similar to this :
> <taskdef name="mapping"
> classname="org.apache.openjpa.jdbc.ant.MappingToolTask"
> classpathref="openjpa.cp"/>
> .  . .
> <mapping sqlFile="${classes.location}/temp.ddl" schemaAction="build">
>     <config dbdictionary="derby"/>
> </mapping>
>
> Hope this helps,
> -mike
>
> On Tue, Dec 16, 2008 at 2:31 PM, Pinaki Poddar <ppoddar@apache.org> wrote:
>
>>
>> $ java org.apache.openjpa.jdbc.meta.MappingTool -sql test.ddl -p
>> persistence.xml
>>
>> classpath should have
>> a) openjpa libraries
>> b) a directory X such that X/META-INF/persistence.xml exists
>>
>> persistence.xml should declare the classes you want to generate DDL for in
>> <class> clause.
>> AFAIR, there were some issues with generating DDL without a database
>> connection. So specify a database configuration in persistence.xml also.
>>
>> If you have many persistence unit defined in persistence.xml but want only
>> a
>> specific persistence unit (say Y) to be processed then append it as
>> follows
>>
>> $ java org.apache.openjpa.jdbc.meta.MappingTool -sql test.ddl -p
>> persistence.xml#Y
>>
>> --
>> View this message in context:
>> http://n2.nabble.com/Can-somebody-tell-me-how-to-generate-DDLs-tp1662488p1664781.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
>>
>

Mime
View raw message