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

  • Home
  • SEARCH
  • 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

I have two classes that are almost identical, besides one method. The classes have
Besides the DateTime ctor (new DateTime(year, month, day)) , is there any other way
Besides using script or an iframe, is there any way to get independently operating
Are there other possibilities besides IIS for hosting web sites and web services based
We're building a module for generating HTML for email newsletters. We've looked into using
Trying to create a grails ant task that has other environments besides prod for
Are there any other CSS validation sites out there besides jigsaw ? It’s saying
I have 3 video files each of 70 MB in my raw folder besides
On some of the controls im using locatisation (language property). Besides default (that is
Basically I want to remove a character in a string one at a time

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.