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 7705877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:58:22+00:00 2026-05-31T23:58:22+00:00

I am setting up a project that uses hibernate, and I am writing the

  • 0

I am setting up a project that uses hibernate, and I am writing the classes and adding annotations to avoid writing .hbm.xml files. I am also trying to use maven hibernate3 plugin specifically hbm2dao and hbm2ddl for dao and database creation but I get the error

failed: Unable to load class declared as <mapping class=package.ClassName.....

hibernate.cfg.xml follows:

<hibernate-configuration>
    <session-factory name="jndi/composite/SessionFactory">
        <property name="hibernate.c3p0.max_size">20</property>
        <property name="hibernate.c3p0.max_statements">50</property>
        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.timeout">1800</property>
        <property name="hibernate.connection.autocommit">false</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.password">PASS</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost/DATABASE</property>
        <property name="hibernate.connection.username">USER</property>
        <property name="hibernate.current_session_context_class">thread</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory    </property>
        <property name="hibernate.use_sql_comments">true</property>
        <mapping class="package.....models.User"/>
    </session-factory>
</hibernate-configuration>

configuration for the plugin on pom.xml

<configuration>
    <components>            
        <component>
            <name>hbm2dao</name>
            <implementation>annotationconfiguration</implementation>
            <outputDirectory>target/generated-sources/hibernate3</outputDirectory>
        </component>
    </components>
    <componentProperties>
        <jdk5>true</jdk5>
        <ejb3>false</ejb3>
        <packagename>package......models</packagename>
        <format>true</format>
        <haltonerror>true</haltonerror>
        <scan-classes>true</scan-classes>
    </componentProperties>
</configuration>

Any info that I may be forgetting just ask, thanks.

  • 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-31T23:58:23+00:00Added an answer on May 31, 2026 at 11:58 pm

    Ok, found a solution to my problem, my main issue is that when using classes on the hibernate.cfg.xml it will use the compiled classes, and not the sources as I was thinking anyway here is how I solved it.

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <executions>
            <execution>
                <id>compile-hibernate-classes</id>
                <phase>generate-sources</phase>
                <goals>
                    <goal>compile</goal>
                </goals>
                <configuration>
                    <includes>
                        <include>FILTER_TO_INCLUDE_HIBERNATE_CLASSES</include>
                    </includes>
                </configuration>
            </execution>
            <execution>
                <id>compile-all</id>
                <phase>compile</phase>
                <goals>
                    <goal>compile</goal>
                </goals>
            </execution>
        </executions>
    </plugin>    
    
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>hibernate3-maven-plugin</artifactId>
        <version>2.2</version>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>hbm2dao</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <components>
                <component>
                    <name>hbm2dao</name>
                    <implementation>annotationconfiguration</implementation>
                    <outputDirectory>target/generated-sources/hibernate3</outputDirectory>
                </component>
                <component>
                    <name>hbm2ddl</name>
                    <implementation>annotationconfiguration</implementation>
                    <outputDirectory>target/generated-sources/hibernate3</outputDirectory>
                </component>
            </components>
            <componentProperties>
                <jdk5>true</jdk5>
                <ejb3>false</ejb3>
                <packagename>PACKAGE_GOES_HERE</packagename>
                <haltonerror>true</haltonerror>
            </componentProperties>
        </configuration>
    </plugin>
    

    So the first execution of the compiler plugin will compile just the classes needed to generate the dao classes, and the second to compile everything.
    The execution on the hibernate plugin will make sure the dao classes are generated when compiling.

    May not be the best way but works for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a website/codeigniter-project that uses views which link to external CSS files. Everywhere
I am currently writing unit tests for a ViewModel in my project that uses
I'm setting up a project that uses SASS, which uses FSEvents to keep from
I'm trying to set up an C++ project in Xcode that uses a Makefile
I am trying to compile a project with MinGW that uses the fltk library.
I have a project that I am setting up through teamcity for CI. The
i have two questions, that i encountered in my learning project 1) Setting: i
I'm setting up a VC++ project in MS Visual Studio 2008 that'll be used
I'm setting up a new project and I want to choose a license that
I'm working on a project that uses Eclipse to build an embedded application for

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.