You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Mail Membrana <ma...@gmail.com> on 2013/09/12 11:32:40 UTC

Generating schema.xml

is there a way to generate schema.xml from existing db schema (this woulb
be prefered way) or from existing POJOs (entities)?

Re: Generating schema.xml

Posted by Thomas Fox <Th...@seitenbau.com>.
> thanks, I found introduction how to generate from jdbc later on
> http://db.apache.org/torque/torque-4.0/documentation/orm-reference/
> running-the-generator.html

I also fixed the docs for the next release so that the information can also
be found on documentation/orm-reference/defining-the-schema.html
(which is where I'd expect the users to look)

> Running generator I get
> [ERROR]
> java.lang.NullPointerException
>    at
>
org.apache.torque.generator.source.jdbc.JdbcMetadataSource.createRootElement

> (JdbcMetadataSource.java:215)
>    at org.apache.torque.generator.source.SourceImpl.getRootElement
> (SourceImpl.java:48)
>    at
> org.apache.torque.generator.control.Controller.processSourceInOutput
> (Controller.java:256)
> ...
>
>  Changed log level to "debug" made clear that some tables have been
> processed, and that error occures for specific table.
>
> Since I do not need all table available in the specified db scheme, I
> have a question how to specify a set of tables for which generation
> should be done?
> Or the generation is done always for whole scheme, that is for all
> tables defined in this scheme?

Currently, it is not possible to run the schema generation for specific
tables only.
However, I have fixed the NullPointerException in the trunk (it was thrown
when an unknown datatype was encountered)
So if you want you can check out the current trunk, build and install it
and then try again withj the 4.1-SNAPSHOT maven plugin.

    Thomas

> 2013/9/12 Thomas Fox <Th...@seitenbau.com>
> >
> > > is there a way to generate schema.xml from existing db schema (this
woulb
> > > be prefered way) or from existing POJOs (entities)?
> >
> > Yes.
> > For maven, fgenerate the schema from the database using jdbc metadata
by:
> >
> >       <plugin>
> >         <groupId>org.apache.torque</groupId>
> >         <artifactId>torque-maven-plugin</artifactId>
> >         <version>4.0</version>
> >         <executions>
> >           <execution>
> >             <id>generate-schema-from-jdbc</id>
> >             <phase>generate-resources</phase>
> >             <goals>
> >               <goal>generate</goal>
> >             </goals>
> >             <configuration>
> >               <packaging>classpath</packaging>
> >
> > <configPackage>org.apache.torque.templates.jdbc2schema</configPackage>
> >
<defaultOutputDir>target/generated-schema</defaultOutputDir>
> >               <defaultOutputDirUsage>none</defaultOutputDirUsage>
> >               <loglevel>info</loglevel>
> >               <options>
> >                 <torque.jdbc2schema.driver>$
> > {driver}</torque.jdbc2schema.driver>
> >                 <torque.jdbc2schema.url>$
> > {database.url}</torque.jdbc2schema.url>
> >                 <torque.jdbc2schema.user>$
> > {database.user}</torque.jdbc2schema.user>
> >                 <torque.jdbc2schema.password>$
> > {database.password}</torque.jdbc2schema.password>
> >               </options>
> >             </configuration>
> >           </execution>
> >         </executions>
> >       </plugin>
> >
> > Note that the generated schema is just a starting point, there is some
> > information missing from jdbc metadata (e.g. foreign keys, indexes,
unique
> > constraints...)
> >
> >    Hope that helps,
> >
> >         Thomas
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Generating schema.xml

Posted by Mail Membrana <ma...@gmail.com>.
thanks, I found introduction how to generate from jdbc later on
http://db.apache.org/torque/torque-4.0/documentation/orm-reference/running-the-generator.html

Running generator I get
[ERROR]
java.lang.NullPointerException
	at org.apache.torque.generator.source.jdbc.JdbcMetadataSource.createRootElement(JdbcMetadataSource.java:215)
	at org.apache.torque.generator.source.SourceImpl.getRootElement(SourceImpl.java:48)
	at org.apache.torque.generator.control.Controller.processSourceInOutput(Controller.java:256)
...

 Changed log level to "debug" made clear that some tables have been
processed, and that error occures for specific table.

Since I do not need all table available in the specified db scheme, I
have a question how to specify a set of tables for which generation
should be done?
Or the generation is done always for whole scheme, that is for all
tables defined in this scheme?



2013/9/12 Thomas Fox <Th...@seitenbau.com>
>
> > is there a way to generate schema.xml from existing db schema (this woulb
> > be prefered way) or from existing POJOs (entities)?
>
> Yes.
> For maven, fgenerate the schema from the database using jdbc metadata by:
>
>       <plugin>
>         <groupId>org.apache.torque</groupId>
>         <artifactId>torque-maven-plugin</artifactId>
>         <version>4.0</version>
>         <executions>
>           <execution>
>             <id>generate-schema-from-jdbc</id>
>             <phase>generate-resources</phase>
>             <goals>
>               <goal>generate</goal>
>             </goals>
>             <configuration>
>               <packaging>classpath</packaging>
>
> <configPackage>org.apache.torque.templates.jdbc2schema</configPackage>
>               <defaultOutputDir>target/generated-schema</defaultOutputDir>
>               <defaultOutputDirUsage>none</defaultOutputDirUsage>
>               <loglevel>info</loglevel>
>               <options>
>                 <torque.jdbc2schema.driver>$
> {driver}</torque.jdbc2schema.driver>
>                 <torque.jdbc2schema.url>$
> {database.url}</torque.jdbc2schema.url>
>                 <torque.jdbc2schema.user>$
> {database.user}</torque.jdbc2schema.user>
>                 <torque.jdbc2schema.password>$
> {database.password}</torque.jdbc2schema.password>
>               </options>
>             </configuration>
>           </execution>
>         </executions>
>       </plugin>
>
> Note that the generated schema is just a starting point, there is some
> information missing from jdbc metadata (e.g. foreign keys, indexes, unique
> constraints...)
>
>    Hope that helps,
>
>         Thomas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


RE: Generating schema.xml

Posted by Thomas Fox <Th...@seitenbau.com>.
> is there a way to generate schema.xml from existing db schema (this woulb
> be prefered way) or from existing POJOs (entities)?

Yes.
For maven, fgenerate the schema from the database using jdbc metadata by:

      <plugin>
        <groupId>org.apache.torque</groupId>
        <artifactId>torque-maven-plugin</artifactId>
        <version>4.0</version>
        <executions>
          <execution>
            <id>generate-schema-from-jdbc</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <packaging>classpath</packaging>

<configPackage>org.apache.torque.templates.jdbc2schema</configPackage>
              <defaultOutputDir>target/generated-schema</defaultOutputDir>
              <defaultOutputDirUsage>none</defaultOutputDirUsage>
              <loglevel>info</loglevel>
              <options>
                <torque.jdbc2schema.driver>$
{driver}</torque.jdbc2schema.driver>
                <torque.jdbc2schema.url>$
{database.url}</torque.jdbc2schema.url>
                <torque.jdbc2schema.user>$
{database.user}</torque.jdbc2schema.user>
                <torque.jdbc2schema.password>$
{database.password}</torque.jdbc2schema.password>
              </options>
            </configuration>
          </execution>
        </executions>
      </plugin>

Note that the generated schema is just a starting point, there is some
information missing from jdbc metadata (e.g. foreign keys, indexes, unique
constraints...)

   Hope that helps,

        Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org