title: Hibernate tool, reverse engineering
body: <p>I have the following question about Hibernate tools and the configuration :
  I configure the hibernate to genrate JPA classes from the database with reverse engineering like this :</p>
  
  <p>hibernate.cfg.xml</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;!DOCTYPE hibernate-configuration PUBLIC
   "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
   &lt;hibernate-configuration&gt;
     &lt;session-factory&gt;
         &lt;property name="hibernate.bytecode.use_reflection_optimizer"&gt;false&lt;/property&gt;
         &lt;property    name="hibernate.connection.driver_class"&gt;oracle.jdbc.OracleDriver&lt;/property&gt;
         &lt;property name="hibernate.connection.password"&gt;pass&lt;/property&gt;
         &lt;property name="hibernate.connection.url"&gt;jdbc:oracle:thin:url&lt;/property&gt;
         &lt;property name="hibernate.connection.username"&gt;user&lt;/property&gt;
         &lt;property name="hibernate.default_schema"&gt;schema&lt;/property&gt;
         &lt;property     name="hibernate.dialect"&gt;org.hibernate.dialect.OracleDialect&lt;/property&gt;
      &lt;/session-factory&gt;
    &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>then I have for reverse engineering the config:</p>
  
  <p>hibernate.reveng.xml</p>
  
  <pre><code>&lt;hibernate-reverse-engineering&gt;
    &lt;table-filter match-name="TB1"/&gt;
      &lt;table name="TB_1" class="com.classtb1"&gt;
       &lt;column name="ENDPAGE" property="pageIntervalEnd"/&gt;
       &lt;column name="SELECTABLE" property="selectableInd"/&gt;
    &lt;/table&gt;
  &lt;/hibernate-reverse-engineering&gt;
  </code></pre>
  
  <p>This is a sample of one table what is mapped in this reverse engineering configuration file.</p>
  
  <p>Now by default all relations from the entities are generated like this :</p>
  
  <pre><code>  @Entity
    @Table(name="TB1"
    )
    public class Classtb1  implements java.io.Serializable {
     ...
          private Set&lt;Classtb1Entry&gt; classtb1= new HashSet&lt;Classtb1Entry&gt;(0);
     ...
         @OneToMany(fetch=FetchType.LAZY, mappedBy="Classtb1")
      public Set&lt;Classtb1Entry&gt; getClasstb1Entries() {
        return this.classtb1Entries;
      }
    }
  </code></pre>
  
  <p>The maven pom.xml file looks like this :</p>
  
  <pre><code>  &lt;profiles&gt;
    &lt;profile&gt;
      &lt;id&gt;WithoutDBGen&lt;/id&gt;
    &lt;/profile&gt;
    &lt;profile&gt;
     &lt;id&gt;Full&lt;/id&gt;
    &lt;activation&gt;
      &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
    &lt;/activation&gt;
    &lt;build&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate3-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.2&lt;/version&gt;
          &lt;executions&gt;
            &lt;execution&gt;
              &lt;id&gt;generate-xml-files&lt;/id&gt;
              &lt;phase&gt;generate-resources&lt;/phase&gt;
              &lt;goals&gt;
                &lt;goal&gt;hbm2cfgxml&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;inherited&gt;false&lt;/inherited&gt;
              &lt;configuration&gt;
                &lt;components&gt;
                  &lt;component&gt;
                    &lt;name&gt;hbm2cfgxml&lt;/name&gt;
                    &lt;implementation&gt;jdbcconfiguration&lt;/implementation&gt;
                  &lt;/component&gt;
                &lt;/components&gt;
                &lt;componentProperties&gt;
                  &lt;packagename&gt;com.persistence.jpa&lt;/packagename&gt;
                  &lt;revengfile&gt;src/main/resources/hibernate.reveng.xml&lt;/revengfile&gt;
                &lt;/componentProperties&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
  
            &lt;execution&gt;
              &lt;id&gt;generate-hbm-xml-files&lt;/id&gt;
              &lt;phase&gt;generate-resources&lt;/phase&gt;
              &lt;goals&gt;
                &lt;goal&gt;hbm2hbmxml&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;inherited&gt;false&lt;/inherited&gt;
              &lt;configuration&gt;
                &lt;components&gt;
                  &lt;component&gt;
                    &lt;name&gt;hbm2hbmxml&lt;/name&gt;
                    &lt;outputDirectory&gt;target/classes&lt;/outputDirectory&gt;
                  &lt;/component&gt;
                &lt;/components&gt;
                &lt;componentProperties&gt;
                  &lt;packagename&gt;com.persistence.jpa&lt;/packagename&gt;
                  &lt;revengfile&gt;src/main/resources/hibernate.reveng.xml&lt;/revengfile&gt;
                  &lt;detectoptmisticlock&gt;false&lt;/detectoptmisticlock&gt;
                &lt;/componentProperties&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
  
            &lt;execution&gt;
              &lt;id&gt;generate-jpa-entities&lt;/id&gt;
              &lt;phase&gt;generate-sources&lt;/phase&gt;
              &lt;goals&gt;
                &lt;goal&gt;hbm2java&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;inherited&gt;false&lt;/inherited&gt;
              &lt;configuration&gt;
                &lt;components&gt;
                  &lt;component&gt;
                    &lt;name&gt;hbm2java&lt;/name&gt;
                    &lt;implementation&gt;annotationconfiguration&lt;/implementation&gt;
                    &lt;outputDirectory&gt;src/main/generated&lt;/outputDirectory&gt;
                  &lt;/component&gt;
                &lt;/components&gt;
                &lt;componentProperties&gt;
                  &lt;packagename&gt;com.persistence.jpa&lt;/packagename&gt;
                  &lt;configurationfile&gt;target/hibernate3/generated-mappings/hibernate.cfg.xml&lt;/configurationfile&gt;
                  &lt;templatepath&gt;target/hibernate3/generated-mappings/&lt;/templatepath&gt;
                  &lt;ejb3&gt;true&lt;/ejb3&gt;
                  &lt;jdk5&gt;true&lt;/jdk5&gt;
                &lt;/componentProperties&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
  
            &lt;execution&gt;
              &lt;id&gt;generate-dao&lt;/id&gt;
              &lt;phase&gt;generate-sources&lt;/phase&gt;
              &lt;goals&gt;
                &lt;goal&gt;hbm2dao&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;inherited&gt;false&lt;/inherited&gt;
              &lt;configuration&gt;
                &lt;components&gt;
                  &lt;component&gt;
                    &lt;name&gt;hbm2dao&lt;/name&gt;
                    &lt;implementation&gt;annotationconfiguration&lt;/implementation&gt;
                    &lt;outputDirectory&gt;src/main/generated&lt;/outputDirectory&gt;
                  &lt;/component&gt;
                &lt;/components&gt;
                &lt;componentProperties&gt;
                  &lt;packagename&gt;com.persistence.dao&lt;/packagename&gt;
                  &lt;configurationfile&gt;target/hibernate3/generated-mappings/hibernate.cfg.xml&lt;/configurationfile&gt;
                  &lt;templatepath&gt;target/hibernate3/generated-mappings/&lt;/templatepath&gt;
                  &lt;ejb3&gt;true&lt;/ejb3&gt;
                  &lt;jdk5&gt;true&lt;/jdk5&gt;
                &lt;/componentProperties&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
  
          &lt;/executions&gt;
  
        &lt;/plugin&gt;
      &lt;/plugins&gt;
      &lt;/build&gt;
      &lt;/profile&gt;
     &lt;/profiles&gt;
  </code></pre>
  
  <p>Where can I configure for one relation like in the case of TB1 to get instead of </p>
  
  <pre><code>@OneToMany(fetch=FetchType.LAZY
  
  i want to generate 
  
  @OneToMany(fetch=FetchType.EAGER ?
  </code></pre>
  
  <p>Where I can configure this option in my case ?</p>
  
  <p>Second problem I have is with the DAO generation, the DAO classes are annotated by default as @Stateless, how can I specify this so my DAO are annotated with another annotation like @Repository or at least no annotation ?</p>