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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:57:56+00:00 2026-05-14T14:57:56+00:00

im new to hibernate! i have followed the netbeans tutorial on creating a hibernate

  • 0

im new to hibernate! i have followed the netbeans tutorial on creating a hibernate enabled application. after sucessfully creating a database in mysql workbench i reversed engineered the pojos etc and then tried to run a simple query(from Course) and got the following

org.hibernate.MappingException: An association from the table coursemodule refers to an unmapped class: DAL.Module
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1252)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1170)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:324)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)

heres the generated class for Course

package DAL;
// Generated 02-May-2010 16:41:16 by Hibernate Tools 3.2.1.GA


import java.util.HashSet;
import java.util.Set;

/**
 * Course generated by hbm2java
 */
public class Course  implements java.io.Serializable {


 private int id;
 private String name;
 private Set<Module> modules = new HashSet<Module>(0);

public Course() {
}


public Course(int id, String name) {
    this.id = id;
    this.name = name;
}
public Course(int id, String name, Set<Module> modules) {
   this.id = id;
   this.name = name;
   this.modules = modules;
}

public int getId() {
    return this.id;
}

public void setId(int id) {
    this.id = id;
}
public String getName() {
    return this.name;
}

public void setName(String name) {
    this.name = name;
}
public Set<Module> getModules() {
    return this.modules;
}

public void setModules(Set<Module> modules) {
    this.modules = modules;
}
}

and its config file course.hbm.xml

<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Generated 02-May-2010 16:41:16 by Hibernate Tools 3.2.1.GA --> <hibernate-mapping>
    <class name="DAL.Course" table="course" catalog="walkthrough">
        <id name="id" type="int">
            <column name="id" />
            <generator class="assigned" />
        </id>
        <property name="name" type="string">
            <column name="name" not-null="true" />
        </property>
        <set name="modules" inverse="false" table="coursemodule">
            <key>
                <column name="courseId" not-null="true" unique="true" />
            </key>
            <many-to-many entity-name="DAL.Module">
                <column name="moduleId" not-null="true" unique="true" />
            </many-to-many>
        </set>
    </class> </hibernate-mapping>

hibernate.reveng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>
  <schema-selection match-catalog="Walkthrough"/>
  <table-filter match-name="walkthrough"/>
  <table-filter match-name="course"/>
  <table-filter match-name="module"/>
  <table-filter match-name="studentmodule"/>
  <table-filter match-name="attendee"/>
  <table-filter match-name="student"/>
  <table-filter match-name="coursemodule"/>
  <table-filter match-name="session"/>
  <table-filter match-name="test"/>
</hibernate-reverse-engineering>

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/Walkthrough</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password">password</property>
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.current_session_context_class">thread</property>
    <mapping resource="DAL/Student.hbm.xml"/>
    <mapping resource="DAL/Walkthrough.hbm.xml"/>
    <mapping resource="DAL/Test.hbm.xml"/>
    <mapping resource="DAL/Module.hbm.xml"/>
    <mapping resource="DAL/Session.hbm.xml"/>
    <mapping resource="DAL/Course.hbm.xml"/>
  </session-factory>
</hibernate-configuration>

any ideas on why im getting this exception?
ps. test is just a table with an id in it and is not related to anything. running “from Test” works

as requested heres the module.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 02-May-2010 16:41:16 by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
    <class name="DAL.Module" table="module" catalog="walkthrough">
        <id name="id" type="int">
            <column name="Id" />
            <generator class="assigned" />
        </id>
        <property name="name" type="string">
            <column name="name" not-null="true" />
        </property>
        <property name="studyLevel" type="int">
            <column name="studyLevel" not-null="true" />
        </property>
        <property name="academicYear" type="int">
            <column name="academicYear" not-null="true" />
        </property>
        <set name="courses" inverse="false" table="coursemodule">
            <key>
                <column name="ModuleId" not-null="true" unique="true" />
            </key>
            <many-to-many entity-name="DAL.Course">
                <column name="CourseId" not-null="true" unique="true" />
            </many-to-many>
        </set>
        <set name="students" inverse="false" table="studentmodule">
            <key>
                <column name="moduleId" not-null="true" unique="true" />
            </key>
            <many-to-many entity-name="DAL.Student">
                <column name="studentId" not-null="true" unique="true" />
            </many-to-many>
        </set>
    </class>
</hibernate-mapping>

after running a unit test on the HibernateUtil class the test failed obtaining the session factory

getSessionFactory
03-May-2010 23:14:27 org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.1.GA
03-May-2010 23:14:27 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.5
03-May-2010 23:14:27 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
03-May-2010 23:14:27 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
03-May-2010 23:14:27 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
03-May-2010 23:14:28 org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
03-May-2010 23:14:28 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
03-May-2010 23:14:28 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : DAL/Student.hbm.xml
03-May-2010 23:14:28 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : DAL/Walkthrough.hbm.xml
03-May-2010 23:14:28 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : DAL/Test.hbm.xml
03-May-2010 23:14:28 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : DAL/Module.hbm.xml
03-May-2010 23:14:28 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : DAL/Session.hbm.xml
03-May-2010 23:14:28 org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource : DAL/Course.hbm.xml
03-May-2010 23:14:28 org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: DAL.Student -> student
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindCollection
INFO: Mapping collection: DAL.Student.modules -> studentmodule
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindCollection
INFO: Mapping collection: DAL.Student.sessions -> attendee
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: DAL.Walkthrough -> walkthrough
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: DAL.Test -> test
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: DAL.Module -> module
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindCollection
INFO: Mapping collection: DAL.Module.courses -> coursemodule
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindCollection
INFO: Mapping collection: DAL.Module.students -> studentmodule
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: DAL.Session -> session
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindCollection
INFO: Mapping collection: DAL.Session.students -> attendee
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: DAL.Course -> course
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindCollection
INFO: Mapping collection: DAL.Course.modules -> coursemodule
03-May-2010 23:14:29 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: DAL.Walkthrough.sessions -> session
03-May-2010 23:14:29 org.hibernate.cfg.AnnotationConfiguration secondPassCompile
INFO: Hibernate Validator not found: ignoring
03-May-2010 23:14:29 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
03-May-2010 23:14:29 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
03-May-2010 23:14:29 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
03-May-2010 23:14:29 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/Walkthrough
03-May-2010 23:14:29 org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=root, password=****}
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: MySQL, version: 5.1.45-community
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
03-May-2010 23:14:30 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
03-May-2010 23:14:30 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Using default transaction strategy (direct JDBC transactions)
03-May-2010 23:14:30 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 2
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
03-May-2010 23:14:30 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
03-May-2010 23:14:30 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
03-May-2010 23:14:30 org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
03-May-2010 23:14:32 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
  • 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-14T14:57:56+00:00Added an answer on May 14, 2026 at 2:57 pm

    The problem is not really Course, the problem is the many-to-many association between Course and Module, the later being not recognized as a mapped class. Do you see any noticeable error messages when you create the SessionFactory? Nothing about Module? Can you show Module.hbm.xml?

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

Sidebar

Related Questions

I am new to Hibernate. I have an exception while running an Hibernate-based application.
I am new to hibernate and I am stumped. In my database I have
I have hibernate.cfg.xml file. <session-factory> <!-- Database connection settings --> <property name=connection.driver_class>com.mysql.jdbc.Driver</property> <property name=connection.url></property>
I am new with hibernate. I have an table in my DB (mySQL) with
I'm quite new to hibernate and have stumbled on this problem, which I can't
Hi i am new to hibernate technology and i have few issues. Suppose if
I'm new to Hibernate and I'm struggling with problem: I have 3 tables and
I'm new to NHibernate... I have been following this NHibernate Tutorial from Gabriel Schenker
im new in hibernate and JPA and i have some problems with annotations. My
I'm new to hibernate. I have a transaction that fails with a HibernateException, yet

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.