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

  • Home
  • SEARCH
  • 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 6562013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:39:31+00:00 2026-05-25T13:39:31+00:00

In JPA using SQL backend, the embedded tables are updated automatically. Is there a

  • 0

In JPA using SQL backend, the embedded tables are updated automatically. Is there a mechanism in NoSQL (MongoDB) to achieve the same?
Here is an example of what I am trying to achieve:
Tables:

Student
Student details
@OnetoMany
Course Details (from another course table)

In JPA and SQL, if the Course Details table is updated the changes are reflected across all the Students referring to it.

In MongoDB instead of using joins the document is embedded inside it. How do we solve this problem in MongoDB?

Thanks,
Sam

  • 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-25T13:39:32+00:00Added an answer on May 25, 2026 at 1:39 pm

    In short, no. It’s also a bit of an apples and oranges question. MongoDB is an SQL replacement in the loosest sense of the word. They’re both databases. JPA is an ORM layer on top of that that can do things like keeping your 1:N and N:M relationships consistent under the hood. There is currently no MongoDB ORM layer that implements JPA or something close to it.

    That said, within the context of a NoSQL database like mongo your schema is not correct. You should not be embedding documents with content that is reused (in most cases, exceptions involve performance optimization where you sacrifice things like normalization for data duplication and thus performance).

    In this case you want a seperate course details collection and store an array of _id values of that course detail in your student document. That way you can modify this collection seperately without having to keep track of mutations of the course details documents.

    Do not use DBRefs references for this. DBRefs are not the appropriate tool for ID references to documents of a known type. Use simple _id references instead.

    So, the TL;DR version :

    • Put course detail documents in seperate collection
    • Embed only an array of _id’s to course detail documents in your student

    Example :

    db.students {
        _id: ..,
        name: Willy Wonka,
        courses: [..,..,..]
    }
    
    db.courses {
        _id: ..,
        course: "MongoDB for Dummies"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Hibernate's implementation of JPA and am seeing poor performance as multiple SQL
Hibernates is generating a VARBINARY column with JPA @Enumerated annotation. I'm using SQL Server
How can I get Hibernate (using JPA) to create MySQL InnoDB tables (instead of
I am using JPA 2.0 and SQL Server 2008 and I have determined that
I'm trying to mix HQL and SQl in the same query. Like using from
I have a problem using JPA with Oracle and grouping by hour. Here's the
When I make relationsships with JPA using hibernate, some terrible long and ackward column
I'm using JPA (Hibernate's implementation) to annotate entity classes to persist to a relational
I'm using JPA in my DAOs outside of Spring . The Spring framework defines
I'm using JPA but I'm not sure how to use it for relation between

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.