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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:57:00+00:00 2026-06-11T17:57:00+00:00

Hi am reading the hibernate documentation. http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/entity.html A many-to-many association is defined logically using

  • 0

Hi am reading the hibernate documentation.

http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/entity.html

A many-to-many association is defined logically using the @ManyToMany
annotation. You also have to describe the association table and the
join conditions using the @JoinTable annotation. If the association is
bidirectional, one side has to be the owner and one side has to be the
inverse end (ie. it will be ignored when updating the relationship
values in the association table):

I understand everything but the last

(ie. it will be ignored when updating the relationship values in the association table).

What does this mean? Example?

  • 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-11T17:57:02+00:00Added an answer on June 11, 2026 at 5:57 pm

    Suppose you have the following entities:

    @Entity
    public class Student {
        @ManyToMany
        private Set<Course> courses;
        ...
    }
    
    @Entity
    public class Course {
        @ManyToMany(mappedBy = "courses")
        private Set<Student> students;
        ...
    }
    

    The owner side is Student (because it doesn’t have the mappedBy attribute). The inverse side is Course ((because it has the mappedBy attribute).

    If you do the following:

    Course course = session.get(Course.class, 3L);
    Student student = session.get(Student.class, 4L);
    student.getCourses().add(course);
    

    Hibernate will add an entry for student 4 and course 3 in the join table because you updated the owner side of the association (student.courses).

    Whereas if you do the following:

    Course course = session.get(Course.class, 3L);
    Student student = session.get(Student.class, 4L);
    course.getStudents().add(student);
    

    nothing will happen, because uou updated the inverse side of the association (course.students), but neglected to updated the owner side. Hibernate only considers the owner side.

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

Sidebar

Related Questions

Reading manual about Sling http://sling.apache.org/site/46-line-blog.html added folder blog and blog.html to destination: \launchpad\content\src\main\resources\content\ but
I'm refreshing my Spring knowledge, reading the reference documentation for spring 3.1. Last time
I have just started reading a Hibernate book and it says go to Hibenrate.org
I am new to Spring and I was just reading the docs about Hibernate-Spring
I was just reading the Hibernate documentation and came across the warning on this
I'm getting this exceptions: javax.el.ELException: Error reading 'id' on type com.example.model.Article_$$_javassist_2 ... org.hibernate.LazyInitializationException: could
I'm having problems with a NonUniqueObjectException thrown by Hibernate. Reading the docs, and this
I tried reading Hibernate documentation. Hibernate One-To-One Fetch is optional - defaults to select,
I've been reading about java/spring/hibernate and worked trough a dummy examples so I told
I spent all of yesterday reading various articles/tutorials on Hibernate and although I am

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.