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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:28:22+00:00 2026-05-14T05:28:22+00:00

I am learning JPA. I read about persistence.xml file. It can contain more that

  • 0

I am learning JPA. I read about persistence.xml file. It can contain more that one <persistence-unit> tag under <persistence> tag.

Upto my undestanding, <persistence-unit> defines:

  • db connection settings
  • classes(entity classes), jar files, and mapping files
  • provider information

Then why would we need to group the entities of our application into different <persistence-unit>. All the entities of any application should be in one <persistence-unit> tag.

The only reason that I think that we need more than one <persistence-unit> is when we need to establish connection with more than one datastore.

Q1. Are there any other situations when we need more than one <persistence-unit> tag?

  • 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-14T05:28:23+00:00Added an answer on May 14, 2026 at 5:28 am

    A persistence unit represents a datastore. Your question has a bit the smell that you expect that you can have more than one datastore for exactly the same data. This makes no sense. The way the <persistence-unit> works makes perfectly sense. Defining the DB connection settings, the entity mappings, etc for an unique and independent datastore. You can add more, but they would be fully independent from each other. If you’d like or expect to link multiple datastores with each other, then the solution should be sought at a lower level, namely in the datastore itself.

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

Sidebar

Related Questions

I am learning JPA and have one question: In which situations we need more
I'm just learning about JPA and session beans. I've worked through a simple database
Learning a little about T-SQL, and thought an interesting exercise would be to generate
I'm learning about table design in SQL and I'm wonder how to create a
I remember first learning about vectors in the STL and after some time, I
I am learning JPA w/Hibernate using a Java SE 6 project. I'd simply like
I am learning JPA from this tutorial . I have some confusions in understanding
Learning how to write JPA query. Please advise me whether it possible to write
I'm still learning how to set up these mappings using the JPA annotations so
For the last three days i am learning JPA by various examples, to change

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.