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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:33:16+00:00 2026-05-13T07:33:16+00:00

Why it isn’t enough to set the @Entity annotation? Am I missing the point

  • 0

Why it isn’t enough to set the @Entity annotation?

Am I missing the point here e.g. performance?

  • 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-13T07:33:16+00:00Added an answer on May 13, 2026 at 7:33 am

    The annotation is not enough because hibernate does not know where your annotated classes live without some sort of explicit declaration. It could, in theory, scan every single class in the classpath and look for the annotation but this would be very very expensive for larger projects.

    You can use spring which has a helper that can allow you to specify the package(s) that your hibernate objects are in and it will just scan these packages for @Entity. If you have all your objects in a small number of fixed packages this works well.

    E.g.

      <bean id="referenceSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="packagesToScan">
          <array>
            <value>com.xxx.hibernate.objects</value>
          </array>
        </property>
      </bean>
    

    The above is the Spring declaration. If you aren’t familiar with the above syntax you can just construct it programmatically.

    AnnotationSessionFactoryBean sfb = new AnnotationSessionFactoryBean();
    sfb.setDataSource( ds );
    sfb.setHibernateProperties( hibProps);
    sfb.setPackagesToScan( ... );
    sfb.initialise();
    SessionFactory sf = sfb.getObject();
    

    It supports a bunch of config options so you can use raw properties or pass in a pre-config’d datasource.

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

Sidebar

Ask A Question

Stats

  • Questions 256k
  • Answers 256k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you'll need to resolve those variables, using the… May 13, 2026 at 10:35 am
  • Editorial Team
    Editorial Team added an answer You can't do that. Instead, you should create a class… May 13, 2026 at 10:35 am
  • Editorial Team
    Editorial Team added an answer I have not used the remote launch/debug facilities, but maybe… May 13, 2026 at 10:35 am

Related Questions

I've been researching WADL and am wondering why it isn't more widely adopted? With
I want to debug a windows C++ application I've written to see why it
http://home.earthlink.net/~benfranq/Sudoku.html Perhaps somebody can tell me why it doesn't work in Internet Explorer In
I read this question and thought that would easily be solved (not that it
It doesn't seem to do this by default, which is pretty shocking to me

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.