maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose Gonzalez Gomez" <>
Subject Fwd: [m2] Frustration getting Maven 2 and Hibernate working together
Date Thu, 06 Jul 2006 07:17:34 GMT
Just in case anybody else needs it...

---------- Forwarded message ----------
From: Jose Gonzalez Gomez <>
Date: 06-jul-2006 8:40
Subject: Re: [m2] Frustration getting Maven 2 and Hibernate working together
To: Paul Kuykendall <>

Ok, here we go...

First of all, add this to settings.xml (in your .m2 directory) in order to
be able to download plugins from the mojo repository:

  <!-- Proxy, servers, whatever you have here -->
  <!-- Access to plugins -->

         <id>Maven Snapshots</id>

Now, declare some dependencies in your pom, including the plugin
configuration and your desired JDBC driver (PostgreSQL in this case):

<?xml version="1.0" encoding="UTF-8"?>




        <version>8.1-407.jdbc3 </version>
  <!-- =============== HIBERNATE PLUGIN =============== -->

          <groupId>javax.persistence </groupId>

Comments on this: first of all, I have no version declared for
persistence-api because I have a parent pom with dependency management (I
will include hibernate-annotations there once I have an stable
configuration); you must include hibernate-annotations as a dependency in
your project only if you want to use hibernate propietary annotations; if
you do include hibernate-annotations you must exclude the
javax.persistence:ejb dependency, as it uses and old draft version I've been
unable to find on the Internet.

Finally you must create your /src/main/resources/hibernate.cfg.xml,
something like this:

<?xml version=' 1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"

  <!-- a SessionFactory instance listed as /jndi/name -->
  <session-factory name="java:hibernate/SessionFactory">
    <!-- properties -->
    <property name="connection.driver_class">org.postgresql.Driver
    <property name="connection.url">jdbc:postgresql://your.server/yourDatabase</property>

    <property name="connection.username">yourUser</property>
    <property name="connection.password">yourPassword</property>
    <property name="dialect"> org.hibernate.dialect.PostgreSQLDialect
    <property name="show_sql">false</property>
    <property name="transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory </property>
    <property name="jta.UserTransaction

    <!-- mapping files -->
    <!-- <mapping package="org.surveyforge.classification " /> -->
    <mapping class="org.surveyforge.classification.Family" />

I was testing a single class, I guess if you have a full package you may use
the commented line to include all the classes. Once I did this, I run mvn
hibernate3:hbm2ddl and the plugin connected to my database and created the
table. I think I don't miss anything...

HTH, best regards

2006/7/5, Paul Kuykendall <>:

> I would be more appreciative than you can ever imagine if you could send
that information.



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message