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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:37:57+00:00 2026-05-15T03:37:57+00:00

i am currently working on one project. In my project there are many entity/POJO

  • 0

i am currently working on one project. In my project there are many entity/POJO files. currently i am using simple hibernate.cfg.xml to add all the mapping files in to the configuration like :-

<mapping resource="xml/ClassRoom.hbm.xml"/>
<mapping resource="xml/Teacher.hbm.xml"/>
<mapping resource="xml/Student.hbm.xml"/>

i am having huge number of mapping files, which makes my hibernate.cfg file looks a bit messy, so is there any way so that i do not need to add the above in to the hibernate.cfg file. rather there can be any other way to achieve the same.. please help

  • 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-15T03:37:57+00:00Added an answer on May 15, 2026 at 3:37 am

    You could create a Configuration programmatically and use Configuration#addClass(Class) to specify the mapped class (and Hibernate will load the mapping file for you). From the javadoc:

    Read a mapping as an application resource using the convention that a class
    named foo.bar.Foo is mapped by a file foo/bar/Foo.hbm.xml
    which can be resolved as a classpath resource.

    So you could do something like this:

    Configuration cfg = new Configuration()
        .addClass(org.hibernate.auction.Item.class)
        .addClass(org.hibernate.auction.Bid.class)
        ...
        .configure();
    SessionFactory factory = cfg.buildSessionFactory();
    

    See also

    • Section 3.1. Programmatic configuration
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a very big project which involves many-to-many and one-to-many
I am currently working on a project where one of our goals is to
I'm currently working on a project with a one page design that'll slide up
In a system I am currently working on, there is one process that loads
I am new to Java web-services and am working on one currently, using Apache
I'm currently working on a small project: there's a protocol for sending some strings
I have a much used project that I am working on currently updating. There
I'm currently working on a project that contains many different Eclipse projects referencing each
I am currently working on php project where I need to upload files, but
I'm working on a simulation project using c++ on both windows and linux. There

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.