jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven 2.x Hibernate Plugin
  • MHIBERNATE-99

Would be nice to have example in documentation for how to use it with overlay builds

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 2.2
  • Fix Version/s: 3.0
  • Component/s: jpaconfiguration
  • Labels:
    None

Description

The hibernate3-maven-plugin works very well in the main project where JPA annotations are used, like this:

<plugin>
                <!-- outputs to target/hibernate3/sql/schema.ddl -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>hbm2ddl</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <components>
                        <component>
                            <name>hbm2ddl</name>
                            <implementation>jpaconfiguration</implementation>
                        </component>
                    </components>
                    <componentProperties>
                        <jdk5>true</jdk5>
                        <propertyfile>src/main/resources/datasource.properties</propertyfile>
                        <!-- set this to whatever was set in persistence.xml -->
                        <persistenceunit>mailPersistence</persistenceunit>
                        <outputfilename>schema.ddl</outputfilename>
                        <drop>false</drop>
                        <create>true</create>
                        <export>false</export>
                        <format>true</format>
                    </componentProperties>
                </configuration>
            </plugin>

However, I have an "overlay" war build that depends on the former war build, like this:

<build>
        <finalName>mailportlet</finalName>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.0</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>exploded</goal>
                    </goals>
                    <configuration>
                      <webappDirectory>target</webappDirectory>
                    </configuration>
                </execution>
            </executions>
          </plugin>          
          <plugin>
              <!-- outputs to target/hibernate3/sql/schema.ddl -->
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>hibernate3-maven-plugin</artifactId>
              <version>2.2</version>
              <executions>
                  <execution>
                      <phase>package</phase>
                      <goals>
                          <goal>hbm2ddl</goal>
                      </goals>
                  </execution>
              </executions>
              <configuration>
                  <components>
                      <component>
                          <name>hbm2ddl</name>
                          <implementation>jpaconfiguration</implementation>
                      </component>
                  </components>
                  <componentProperties>
                      <jdk5>true</jdk5>
                      <propertyfile>src/main/resources/datasource.properties</propertyfile>
                      <!-- set this to whatever was set in persistence.xml -->
                      <persistenceunit>mailPersistence</persistenceunit>
                      <outputfilename>schema.ddl</outputfilename>
                      <drop>false</drop>
                      <create>true</create>
                      <export>false</export>
                      <format>true</format>
                  </componentProperties>
              </configuration>
          </plugin>
        </plugins>
    </build>

Basically what I'm trying to do is to overlay the war (part of which modifies the hibernate.dialect), then explode it so that the Maven 2.x Hibernate Plugin could in-theory access the JPA configuration and the JPA annotated model classes. However, this doesn't work.

Any ideas about how I could accomplish this? It would be great to have an example of this type of usage in the documentation as well, if it is possible, and if it isn't possible, it would be a great enhancement to somehow allow this type of use.

Thanks in advance for any help,
Gary

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Gary S. Weaver added a comment - 23/Oct/09 4:05 PM

If you are curious, here is the difference in output:

[INFO] [hibernate3:hbm2ddl {execution: default}]
17:04:15,417  INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA
17:04:15,424  INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
17:04:15,427  INFO org.hibernate.cfg.Environment - hibernate.properties not found
17:04:15,429  INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
17:04:15,431  INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
17:04:15,466  INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA
17:04:15,468  INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.4.0.GA
17:04:15,963  INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: org.jasig.portlet.mail.model.impl.MailAccountImpl
17:04:15,985  INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity org.jasig.portlet.mail.model.impl.MailAccountImpl on table MAIL_ACCOUNT
17:04:16,037  INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: org.jasig.portlet.mail.model.impl.MailAccountSetImpl
17:04:16,037  INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity org.jasig.portlet.mail.model.impl.MailAccountSetImpl on table MAIL_ACCOUNT_SET
17:04:16,056  INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: org.jasig.portlet.mail.model.impl.MailCredentialsImpl
17:04:16,057  INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity org.jasig.portlet.mail.model.impl.MailCredentialsImpl on table MAIL_ACCOUNT_CREDENTIAL
17:04:16,095  INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping collection: org.jasig.portlet.mail.model.impl.MailAccountSetImpl.accounts -> MAIL_ACCOUNT
17:04:16,098  INFO org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
[INFO] No hibernate configuration file loaded.
[INFO] Configuration Properties file loaded: .../src/main/resources/datasource.properties
17:04:16,117  INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.HSQLDialect
17:04:16,138  INFO org.hibernate.tool.hbm2ddl.SchemaExport - Running hbm2ddl schema export
17:04:16,138  INFO org.hibernate.tool.hbm2ddl.SchemaExport - writing generated schema to file: .../target/hibernate3/sql/schema.ddl
 ...
17:04:16,139  INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
17:03:18,394  INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA
17:03:18,403  INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
17:03:18,405  INFO org.hibernate.cfg.Environment - hibernate.properties not found
17:03:18,408  INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
17:03:18,410  INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
17:03:18,449  INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA
17:03:18,451  INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.4.0.GA
17:03:18,756  INFO org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
[INFO] No hibernate configuration file loaded.
[INFO] No hibernate properties file loaded.
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The dialect was not set. Set the property hibernate.dialect.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
	at org.hibernate.dialect.Dialect.instantiateDialect(Dialect.java:256)
	at org.hibernate.dialect.Dialect.getDialect(Dialect.java:234)
	at org.hibernate.dialect.Dialect.getDialect(Dialect.java:249)
	at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:121)
	at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91)
	at org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo.doExecute(Hbm2DDLExporterMojo.java:96)
	at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152)
	at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:453)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:500)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:479)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:331)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:292)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:288)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:592)
	at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
	at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
	at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Show
Gary S. Weaver added a comment - 23/Oct/09 4:05 PM If you are curious, here is the difference in output:
[INFO] [hibernate3:hbm2ddl {execution: default}]
17:04:15,417  INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA
17:04:15,424  INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
17:04:15,427  INFO org.hibernate.cfg.Environment - hibernate.properties not found
17:04:15,429  INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
17:04:15,431  INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
17:04:15,466  INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA
17:04:15,468  INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.4.0.GA
17:04:15,963  INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: org.jasig.portlet.mail.model.impl.MailAccountImpl
17:04:15,985  INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity org.jasig.portlet.mail.model.impl.MailAccountImpl on table MAIL_ACCOUNT
17:04:16,037  INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: org.jasig.portlet.mail.model.impl.MailAccountSetImpl
17:04:16,037  INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity org.jasig.portlet.mail.model.impl.MailAccountSetImpl on table MAIL_ACCOUNT_SET
17:04:16,056  INFO org.hibernate.cfg.AnnotationBinder - Binding entity from annotated class: org.jasig.portlet.mail.model.impl.MailCredentialsImpl
17:04:16,057  INFO org.hibernate.cfg.annotations.EntityBinder - Bind entity org.jasig.portlet.mail.model.impl.MailCredentialsImpl on table MAIL_ACCOUNT_CREDENTIAL
17:04:16,095  INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping collection: org.jasig.portlet.mail.model.impl.MailAccountSetImpl.accounts -> MAIL_ACCOUNT
17:04:16,098  INFO org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
[INFO] No hibernate configuration file loaded.
[INFO] Configuration Properties file loaded: .../src/main/resources/datasource.properties
17:04:16,117  INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.HSQLDialect
17:04:16,138  INFO org.hibernate.tool.hbm2ddl.SchemaExport - Running hbm2ddl schema export
17:04:16,138  INFO org.hibernate.tool.hbm2ddl.SchemaExport - writing generated schema to file: .../target/hibernate3/sql/schema.ddl
 ...
17:04:16,139  INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
17:03:18,394  INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA
17:03:18,403  INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
17:03:18,405  INFO org.hibernate.cfg.Environment - hibernate.properties not found
17:03:18,408  INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
17:03:18,410  INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
17:03:18,449  INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA
17:03:18,451  INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.4.0.GA
17:03:18,756  INFO org.hibernate.cfg.AnnotationConfiguration - Hibernate Validator not found: ignoring
[INFO] No hibernate configuration file loaded.
[INFO] No hibernate properties file loaded.
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The dialect was not set. Set the property hibernate.dialect.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
	at org.hibernate.dialect.Dialect.instantiateDialect(Dialect.java:256)
	at org.hibernate.dialect.Dialect.getDialect(Dialect.java:234)
	at org.hibernate.dialect.Dialect.getDialect(Dialect.java:249)
	at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:121)
	at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91)
	at org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo.doExecute(Hbm2DDLExporterMojo.java:96)
	at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152)
	at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:453)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:559)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:500)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:479)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:331)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:292)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:288)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:592)
	at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
	at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
	at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

People

  • Assignee:
    Johann Reyes
    Reporter:
    Gary S. Weaver
Vote (0)
Watch (0)

Dates

  • Created:
    23/Oct/09 4:01 PM
    Updated:
    14/Jan/10 10:00 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.