Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3756756
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:54:03+00:00 2026-05-19T09:54:03+00:00

Besides generating other source files, I want to generate one factory class for DAO

  • 0

Besides generating other source files, I want to generate one factory class for DAO classes – DAOFactory.java. I’m using hbmtemplate for that purpose – with my own *.ftl file.
Problem is that (as I understand correctly) file is generated for each entity in database. Is it possible to generate that file only once?

Part of my pom.xml:

<execution>
  <id>hbmtemplate0</id>
  <phase>generate-sources</phase>
  <goals>
   <goal>hbmtemplate</goal>
  </goals>
  <configuration>
   <components>
    <component>
     <name>hbmtemplate</name>
     <outputDirectory>src/main/java</outputDirectory>
    </component>
   </components>
   <componentProperties>
    <revengfile>/src/main/resources/hibernate.reveng.xml</revengfile>
    <propertyfile>src/main/resources/database.properties</propertyfile>
    <jdk5>false</jdk5>
    <ejb3>false</ejb3>
    <packagename>my.package.name</packagename>
    <format>true</format>
    <haltonerror>true</haltonerror>
    <templatepath>src/main/resources/reveng.templates/</templatepath>
    <filepattern>DAOFactory.java</filepattern>
    <template>DAOFactory.java.ftl</template>
   </componentProperties>
  </configuration>
</execution>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:54:04+00:00Added an answer on May 19, 2026 at 9:54 am

    a) generated code should usually not go in src/main/java!!!! Use target/generated-sources/somefoldername (or rather: ${project.build.directory}/generated-sources/somefoldername) instead! Otherwise your generated code will end up in your SCM and that’s when things get messy. As a rule of thumb: everything you edit is in src, everything maven creates or edits is in target.

    If the hibernate tools don’t automatically add the generated source dir to the compiler’s source roots, you can do that with the buildhelper-maven-plugin:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>
             <execution>
                <id>add-source</id>
                <phase>process-sources</phase>
                <goals>
                    <goal>add-source</goal>
                </goals>
                <configuration>
                    <sources>
                        <source>
    ${project.build.directory}/generated-sources/somefoldername
                        </source>
                  </sources>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

    b) It appears that you can not restrict it to a single class. So one thing you could do is to delete the generated java files you don’t need. The standard way to do things like that is to use the antrun plugin:

    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.6</version>
      <executions>
        <execution>
          <phase>process-sources</phase>
          <configuration>
            <target>
              <delete>
                <fileset
                  dir="${project.build.directory}/generated-sources/somefoldername"
                  includes="**/*.java" excludes="**/ClassYouWantToKeep.java" />
              </delete>
            </target>
          </configuration>
          <goals>
            <goal>run</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Besides transporting captcha imgs & copy-righted imgs, is there any other reason why one
Besides readability is there any significant benifit to using a CASE WHEN statement vs
Besides a drag-and-drop UI designer are there any other missing features when developing for
Besides the existence of Smarty.class.php (which is also arguable), how do we know that
besides using Hive, is it a good idea in order to execute ad hoc
Which other languages besides English does Levenshtein distance support its implementation? I know that
Besides missing some of the benefits of Event Sourcing, are there any other drawbacks
Besides 'new', 'delete', '<<' & '>>' operators, what other operators can be overloaded in
Beside's Ivy's built-in makepom task, I can't find any (Java-centric) open source projects that
I am trying to clean up warnings R# 6.1 is generating for my classes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.