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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:14:53+00:00 2026-05-13T11:14:53+00:00

As of now I have a working Spring application with persistence. However now I

  • 0

As of now I have a working Spring application with persistence. However now I want to use Hibernate with JPA to do all of my database activities. I want to do this using an entitymanager.

I’ve been reading many documents and tutorials on this matter, I’ve been getting confused on whether I need a persistence.xml file or not. Also I’ve been getting confused on how to setup my applicationContext.xml file as well.

Does anybody know of a good site to look at in order to learn Spring + Hibernate + JPA + using EntityManager?

  • 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-13T11:14:53+00:00Added an answer on May 13, 2026 at 11:14 am

    I’ve just spent the last couple of weeks trying to set up the same kind of project.

    You do need a persistence.xml file, and it belongs in META-INF

    Here is an example of my spring beans file for persistence:

    <beans  xmlns="http://www.springframework.org/schema/beans" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
    <context:property-placeholder location="/WEB-INF/config.properties" />
    
        <tx:annotation-driven />
    
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> 
        <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>
    
    <bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate"> 
        <property name="entityManagerFactory" ref="entityManagerFactory" />
    </bean>
    
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
        <property name="driverClassName" value="${db.driver}" /> 
        <property name="url" value="${db.url}" /> 
        <property name="username" value="${db.user}" /> 
        <property name="password" value="${db.password}" />
    </bean>
    
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
        <property name="persistenceUnitName" value="whatisayis" />
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter"> 
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> 
                <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> 
                <property name="showSql" value="true" /> 
                <property name="generateDdl" value="true" />
            </bean> 
        </property>
    </bean>
    
    <bean id="leDAO" class="com.noisyair.whatisayis.dao.jpa.JpaLearningEntryDAO">
        <property name="jpaTemplate" ref="jpaTemplate" />
    </bean> 
    <bean id="sampleDAO" class="com.noisyair.whatisayis.dao.jpa.JpaSampleDAO">
        <property name="jpaTemplate" ref="jpaTemplate" />
    </bean>
        <bean id="tagDAO" class="com.noisyair.whatisayis.dao.jpa.JpaTagDAO">
        <property name="jpaTemplate" ref="jpaTemplate" />
    </bean>
    </beans>
    

    Also, I am using Maven to pull in the spring3 and hibernate dependencies i need.

    edit: for a learning resource I highly recommend “Spring Recipes A Problem-Solution Approach” by Gary Mac http://www.apress.com/book/view/9781590599792. This is one of the best technical books I’ve ever read, and it will surely help you get up and running with Spring/JPA/Hibernate.

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

Sidebar

Related Questions

i have a Spring application and its working well so far. Now i want
I have a working web application that uses username/password SpringSecurity configuration. Now I want
I'm working on a REST application with Spring-data Hibernate etc.. I've setup all my
I am currently working on kerberos, and for now have this doubt on PAC
I have been working on this problem for 2 days now and it's an
I have been working on this problem for a while now. I am trying
I have been working on this for 24 hours now, trying to optimize it.
I have been working on this for some time now and just cant quite
i have been working on this sub-menu for 8 hours now, the last little
This is driving me nuts. I have a working text based application. It has

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.