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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:41:04+00:00 2026-06-11T13:41:04+00:00

My requirement is to map various database (particularly SQL Server, MySQl and Postgres) using

  • 0

My requirement is to map various database (particularly SQL Server, MySQl and Postgres) using hibernate ; from db record create a xml file.

For hibernate i am creating hbm files and pojos at run-time using JAssist.
My code works great, for further modularization i implement fragment bundles for each database.so that my host bundle will handle runtime class creation and adding them in classloader, hbm file creation logic, and BL. fragment calls it by passing parameters.

when i create a fragment bundle for each database,
the runtime pojo class created in my host bundle is visible in my fragment bundle,
i checked with “Thread.currentThread().getContextClassLoader().loadClass()”
and able to create its instance,

The Problem is
when i call Hibernate functions from fragment bundle, I am getting “Entity not mapped”, AFAIK These exception comes when hibernate is unable to find the mapping class with table.
So i guess Hibernate is not finding my runtime pojo classes. which it can find in host.

Host :
Runtime Pojo creation,
HBM and CFG creation and updation logic
BL

Fragment :
Hibernate layer,
Calling Hibernate function,
XML Creation logic

  • 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-06-11T13:41:04+00:00Added an answer on June 11, 2026 at 1:41 pm

    This problem always appears if you use Hibernate over more than one bundle. In the Hibernate configuration you can’t tell in which Bundle the mapping files and the pojo class files can be found. Hibernate does not use the mechanisms which OSGI provides for this. As a result hibernate only finds mapping files and classes which are in the same bundle as the Hibernate library.

    I don’t know if there is anywhere a professional solution (a third party product) for this problem.

    There are two possibilities to solve this problem:

    1. Forget your fragment bundles and put all Hibernate libraries, mapping files, pojos, classes using Hibernate/HQL for all databases into a single bundle. You can switch between different databases when you use different hibernate.cfg.xml files; each database has its own configuration file. These hibernate.cfg.xml files can be outside the bundles.

    2. Write your own Configuration class which extends org.hibernate.cfg.Configuration, In this class you have to

      • write your own class loader which finds the pojo classes even in other bundles
      • override addResource(String resourceName, ClassLoader classLoader) in a way it finds resources also in other bundles
      • override doConfigure and buildSessionFactory so they use your class loader instead of the standard class loader (use Thread.setContextClassLoader and call the method from the super class, i. e. from the standard Hibernate Configuration class).
      • override all the other methods which return an instance of Configuration so they return the instance of your Configuration class and not of the Hibernate Configuration class.

    We did solution 2. It was a bit of work, but now it is running well. (Thought, when changing the Hibernate version again a bit of work might be necessary.)

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

Sidebar

Related Questions

Requirement : Should update MySQL database with that of MS Sql Server updates which
My requirement is to display tables from database in Graph format and I am
I need to store map bounds in a MySQL database. I've spent some time
I have a simple requirement, i need a map of type . however i
Requirement is this ... We have our 3 web-applications deployed in RHEL-5 server, we
Requirement is like: I want to take input values from user in frame but
Requirement: I need to run multiple animations one by one. I'm using onAnimationEnd() to
I am working on the map application and as per requirement i need to
I'm implementing a Google Map on a website. One requirement is to display a
I have a requirement to allow users in a content management system to create

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.