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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:15:19+00:00 2026-05-15T16:15:19+00:00

My current web development tool is Spring 3, I’ve used Hibernate before, I’m actually

  • 0

My current web development tool is Spring 3, I’ve used Hibernate before, I’m actually quite familiar with it after I have access to the annotations and entities, and the session object. However, this will be my first time needing to actually set it up from scratch.

Currently I have a datasource that I have used for JDBCTemplate, and I want to reuse that for Hibernate.

Unfortunately, the more I read about Hibernate, the more confused I get. There are many different ways to configure it, and things have changed quite a bit since some of the tutorials. Most confusing is that sometimes a persistence.xml file is used, sometimes a hibernate config XML file.

Then there are session factories, but then there are also entity manager factories. Could someone please distill some of this information so I have a bit more of a clear path ahead of me.

My only real requirements are that I can use the annotations with Hibernate. I’d like to have support for transactions too.

I know this question is somewhat vague, but it’s because I’ve been unable to actually find a solid “tutorialized” solution that is up to date with spring 3 that I trust.

  • 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-15T16:15:20+00:00Added an answer on May 15, 2026 at 4:15 pm

    Currently I have a datasource that I have used for JDBCTemplate, and I want to reuse that for Hibernate.

    No problem. I’d just mention that accessing the same tables through both Hibernate and JDBC will require some precautions.

    (…) Most confusing is that sometimes a persistence.xml file is used, sometimes a hibernate config XML file.

    The hibernate.cfg.xml is Hibernate native configuration file. The persistence.xml is the JPA (the standardized Java Persistence API) configuration file. If you decide to go the JPA way (and this would be my recommendation), you usually use the persistence.xml only. And if you use Spring, most configuration will actually end up in Spring configuration file in any case.

    Then there are session factories, but then there are also entity manager factories. Could someone please distill some of this information so I have a bit more of a clear path ahead of me.

    Same story as above. The SessionFactory (and Session) are classes from Hibernate’s native API while the EntityManagerFactory and EntityManager are somehow the JPA “counterparts”. If you go the JPA way, you’ll deal with the EntityManagerFactory and EntityManager.

    My only real requirements are that I can use the annotations with Hibernate. I’d like to have support for transactions too.

    As already mentioned, my suggestion would be to use the standardized JPA API (and to use Hibernate proprietary extensions only if strictly required). For transactions, use Spring.

    The section 12.6. JPA of the documentation covers everything you’ll need to configure Spring (I suggest to use the LocalContainerEntityManagerFactoryBean that you’ll feed with your datasource).

    For the data access layer (the DAOs) either use the JpaTemplate and JpaDaoSupport classes or implement DAOs based on plain JPA using an injected EntityManagerFactory or EntityManager (I personally use the later approach).

    All these references to the Spring 2.5 documentation are still valid with Spring 3.0. Just in case, here is a not too old tutorial that could help you to get started.

    See also

    • Similarity and difference between JPA and Hibernate
    • Difference Hibernate 3.5 / JPA 2.0
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Current I use Django and Python for web development. I know Java, Spring ,
I have a simple class that contains some general information about the current web
I have been reviewing the setup of a current Amazon Web Store implementation to
Is HttpContext.Current ever null in a web Application (assuming threads are not being used)?
I am trying to make some enhancements to a production web app. After quite
In the current web development world with mobile devices kicking in, Browser wars still
What is the current state of Push technology in web development? I heard solutions
I'm completely new to the Spring framework (and most web development in general), but
I'm following Agile web development with rails book. I have a problem. this is
I have been out of the loop with web development for about a year

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.