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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:31:34+00:00 2026-06-17T00:31:34+00:00

For example if i have following tables in my database and Student and Course

  • 0

For example if i have following tables in my database and Student and Course has many to many relationship.

Student
-------
Id (Primary Key)
FirstName
LastName

Course
------
Id (Primary Key)
Title

StudentCourse
-------------
StudentId (Foreign Key -> Student)
CourseId (Foreign Key -> Course)

Now if my model is as follows

public class Student
{
  private int ID;
  private String firstName;
  private String lastName;

  //getter and setter
}

and

public class Course
{
private int ID;
pirvate String title;
//getter and setter
}

So my question is if i create only these two beans what sort of problem will i encounter?What sort of problem will i face and in which condition?And please specify the correct bean structure for such many to many relationship.

  • 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-06-17T00:31:35+00:00Added an answer on June 17, 2026 at 12:31 am

    What problems will you encounter:

    • You won’t be able to see the Student – Course associations
    • You won’t be able to navigate from a Course to the Students on the Course (and vice-versa)
    • You will have problems deleting a Student/Course, if its in the StudentCourse table (foregin key violation)

    Generally: you don’t want it like this.

    Possible solution: use an ORM system, like Hibernate, EclipseLink or OpenJPA. Then you can have a private List<Student> students; in your Course entity (entity is a better name here than bean, imho), and/or a private List<Course> courses; in the Student entity.

    To make the actual association between the List<> fields and the connecting table in the database, you need to configure the mapping (which is the configuration the ORM uses to bridge the gap between the database schema and the entities).

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

Sidebar

Related Questions

Let's say I have the following tables in a database forming a Many-to-Many Relationship.
I have models corresponding to database tables. For example, the House class has color,
Say for example, I have the following two tables: TableA { _id } TableB
For example, let's say I have the following two tables: Table1: Id ---- 1
I have following tables in my MySql database : +----------------------------------------------+ PROJECT +----------------------------------------------| +----------------------------------------------| project_id
I have the following tables in my Reward System's database: purchases => Purchase_ID ,
Hi all i have the following table called student in SQLite database. this is
I have the following tables in my database: Employee Table which consists of Name,
I have the following tables within a database, that I am using to store
Lets say I have the following 2 tables in a database: [Movies] (Scheme: Automatic)

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.