Configuring hibernate3-maven-plugin

View: New views
5 Messages — Rating Filter:   Alert me  

Configuring hibernate3-maven-plugin

by Ryan Stewart :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've read the plugin pages at:
http://mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/

But they're sparse at best. I get the idea that the hibernate3 maven plugin is generally supposed to be configured in the same way as the Hibernate Tools Ant task, but there's one particular thing I can't see how to do. I'm trying to convert an existing hbm2ddl ant task that looks like this:
        <hibernatetool destdir="${ddl.dir}">
            <classpath refid="java.classpath" />
            <configuration propertyfile="${hibernatetools.properties.dir}/hibernate.properties">
                <fileset refid="some.db.mappings" />
                <fileset refid="other.db.mappings" />
            </configuration>
            <hbm2ddl outputfilename="schema-gen.ddl.sql" format="true" />
            <hbm2ddl update="true" create="false" />
        </hibernatetool>

I think I can see how to set the configuration to "configuration" (as opposed to, say jdbcconfiguration) and how to specify the propertyfile. The outputfilename, format, update, and create seem to be pretty self-evident as well. I haven't been able to test them though, because I can't see how to specify to the hibernate3 maven plugin where my mapping files are. Any clues? Is there a way to do it similar to the fileset approach in the Ant task above, or am I going to have to create a hibernate.cfg.xml? I don't have one of those because the Hibernate config is handled by Spring. Even that hibernate.properties file referenced by the Ant task is generated by the build itself. There is no Hibernate-related configuration outside of Spring.

Re: Configuring hibernate3-maven-plugin

by Rusty Wright-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ryan, did you figure this out?  I have my hibernate config files in src/main/hbm and added that as a resource in my pom.xml:

    <build>
        <resources>
            <resource>
                <directory>src/main/hbm</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <!-- output goes to target/hibernate3 -->
                    <components>
                        <component>
                            <name>hbm2java</name>

                            <implementation>
                                jdbcconfiguration
                            </implementation>
                        </component>

                        <component>
                            <name>hbm2hbmxml</name>

                            <implementation>
                                annotationconfiguration
                            </implementation>
                        </component>

                        <component>
                            <name>hbm2cfgxml</name>

                            <implementation>
                                annotationconfiguration
                            </implementation>
                        </component>

                        <component>
                            <name>hbm2doc</name>

                            <implementation>
                                annotationconfiguration
                            </implementation>
                        </component>

                        <component>
                            <name>hbm2ddl</name>

                            <implementation>
                                annotationconfiguration
                            </implementation>
                        </component>

                        <component>
                            <name>hbm2dao</name>

                            <implementation>
                                annotationconfiguration
                            </implementation>
                        </component>
                    </components>

                    <componentProperties>
                        <!-- the cfg file arrives here after maven has      -->
                        <!-- filtered it.                                   -->
                        <configurationfile>
                            target/classes/hibernate.cfg.xml
                        </configurationfile>

                        <format>true</format>

                        <!-- hbm2java -->
                        <jdk5>true</jdk5>

                        <!-- hbm2java, hbm2cfgxml -->
                        <ejb3>true</ejb3>

                        <!-- hbm2ddl -->
                        <export>true</export>
                        <update>false</update>
                        <drop>true</drop>
                        <create>true</create>
                        <format>true</format>
                        <outputfilename>ddl.sql</outputfilename>

                        <!-- when this is true then failing drops cause a   -->
                        <!-- build failure. this would happen when the      -->
                        <!-- database is empty or if adding a new table.    -->
                        <!-- normally true for postgres, false for hsql.    -->
                        <!-- when adding new tables, etc. just run          -->
                        <!-- mvn hibernate3:hbm2ddl twice to get past the   -->
                        <!-- missing table errors.                          -->
                        <haltonerror>${hbmtool.haltOnError}</haltonerror>
                    </componentProperties>
                </configuration>
            </plugin>

etc.



Ryan Stewart wrote:

> I've read the plugin pages at:
> http://mojo.codehaus.org/maven-hibernate3/hibernate3-maven-plugin/
>
> But they're sparse at best. I get the idea that the hibernate3 maven plugin
> is generally supposed to be configured in the same way as the Hibernate
> Tools Ant task, but there's one particular thing I can't see how to do. I'm
> trying to convert an existing hbm2ddl ant task that looks like this:
>         <hibernatetool destdir="${ddl.dir}">
>             <classpath refid="java.classpath" />
>             <configuration
> propertyfile="${hibernatetools.properties.dir}/hibernate.properties">
>                 <fileset refid="some.db.mappings" />
>                 <fileset refid="other.db.mappings" />
>             </configuration>
>             <hbm2ddl outputfilename="schema-gen.ddl.sql" format="true" />
>             <hbm2ddl update="true" create="false" />
>         </hibernatetool>
>
> I think I can see how to set the configuration to "configuration" (as
> opposed to, say jdbcconfiguration) and how to specify the propertyfile. The
> outputfilename, format, update, and create seem to be pretty self-evident as
> well. I haven't been able to test them though, because I can't see how to
> specify to the hibernate3 maven plugin where my mapping files are. Any
> clues? Is there a way to do it similar to the fileset approach in the Ant
> task above, or am I going to have to create a hibernate.cfg.xml? I don't
> have one of those because the Hibernate config is handled by Spring. Even
> that hibernate.properties file referenced by the Ant task is generated by
> the build itself. There is no Hibernate-related configuration outside of
> Spring.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Configuring hibernate3-maven-plugin

by Ryan Stewart :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Rusty Wright-2 wrote:
Ryan, did you figure this out?  I have my hibernate config files in src/main/hbm and added that as a resource in my pom.xml:
[...]
No, I never got that ironed out. I think I see what you're getting at, but I haven't had time to mess with that again recently. If I figure out a good solution, I'll try to remember to post it back here.

Re: Configuring hibernate3-maven-plugin

by Rusty Wright-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The only thing I think I used ant for, which I haven't used in a while, was for extracting the ddl from the database.  I'm using jpa/hibernate annotations and the hibernate tools create the tables.  Let me know and if you need something to look at I can send you a zip of the project.


Ryan Stewart wrote:

>
> Rusty Wright-2 wrote:
>> Ryan, did you figure this out?  I have my hibernate config files in
>> src/main/hbm and added that as a resource in my pom.xml:
>> [...]
>>
>
> No, I never got that ironed out. I think I see what you're getting at, but I
> haven't had time to mess with that again recently. If I figure out a good
> solution, I'll try to remember to post it back here.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



RE: Configuring hibernate3-maven-plugin

by Johann Reyes-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Ryan

You can do it the following way with the new test version of the plugin:

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>hibernate3-maven-plugin</artifactId>
        <version>3.0-SNAPSHOT</version>
        <configuration>
          <hibernatetool>
            <configuration/>
            <hbm2ddl outputfilename="schema-gen.ddl.sql" format="true" />
            <hbm2ddl update="true" create="false" />
          </hibernatetool>
        </configuration>
      </plugin>

Regards

Johann Reyes

-----Original Message-----
From: Ryan Stewart [mailto:rds6235@...]
Sent: Wednesday, July 08, 2009 8:16 PM
To: user@...
Subject: Re: [mojo-user] Configuring hibernate3-maven-plugin



Rusty Wright-2 wrote:
>
> Ryan, did you figure this out?  I have my hibernate config files in
> src/main/hbm and added that as a resource in my pom.xml:
> [...]
>

No, I never got that ironed out. I think I see what you're getting at, but I
haven't had time to mess with that again recently. If I figure out a good
solution, I'll try to remember to post it back here.
--
View this message in context:
http://www.nabble.com/Configuring-hibernate3-maven-plugin-tp23843685p2440173
9.html
Sent from the mojo - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email