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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:09:51+00:00 2026-06-14T13:09:51+00:00

I am creating session factory by reading properties file which is outside from by

  • 0

I am creating session factory by reading properties file which is outside from by project.
My Properties file is as follows,

hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.username=root
hibernate.connection.password=root
hibernate.connection.url=jdbc:mysql://localhost:3306/hi5
hibernate.dialect=org.hibernate.dialect.MySQLDialect
entity=CmtFreeformpages,CmtNewsTicker

I am creating Sessionfactory by reading the properties file as follows,

properties.load(new FileReader(new File(global.constants.GlobalConstants.parentDirectory + File.separator + global.constants.GlobalConstants.propertiesFile)));
Configuration configuration = new Configuration().setProperties(properties);
Set<Object> setOfProperties = properties.keySet();
for(Object propertyObject : setOfProperties){
if (propertyObject != null) {
String propName = propertyObject.toString();
if(propName.equalsIgnoreCase("entity")){
String value = properties.getProperty(propName);
Object[] entities = value.split(",");
for(int i=0;i<entities.length;i++){
 configuration.addAnnotatedClass(entities[i]);
}
sessionFactory = configuration.buildSessionFactory();

but configuration.addAnnotatedClass method is not accepting the string.So how to add the annotated classes to the configuration ?

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-06-14T13:09:52+00:00Added an answer on June 14, 2026 at 1:09 pm

    Since addAnnotatedClass() accepts a Class, you need to get Classes for the given class names using Class.forName():

    configuration.addAnnotatedClass(Class.forName(entities[i]));
    

    Note that Class.forName() expects fully qualified class names, i.e. with package names included.

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

Sidebar

Related Questions

Possible Duplicate: Firefox session cookies I'm creating a website in which users are allowed
I am creating a web app which uses jQuery to authenticate: $.ajax({ url: /session/create?format=json,
When I open a session with var session = factory.OpenSession(); and check session.Connection.State it
I'm using NHibernate mapping by code and I'm creating the session factory in this
is it possible to insert an object into a session instead of creating a
Creating a class at runtime is done as follows: klass = Class.new superclass, &block
I have different hibernate session factories on different machines for accessing single db instance
I'm currently working on creating a custom connection provider for HNibernate very similar to
I am trying to develop a web project using Hibernate 4 and spring 3.1.
I'd like to have a single configuration file and then when I'm creating a

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.