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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:27:54+00:00 2026-05-27T15:27:54+00:00

In a simplified situation like this one, with 3 classes: class ClassONE{ protected List<IntermediatedClass>;

  • 0

In a simplified situation like this one, with 3 classes:

class ClassONE{

   protected List<IntermediatedClass>;

   (... getters / setters)

}

class ClassTWO

 protected String someData;

 (... getters / setters / iniciate List etc...)

}

class IntermediatedClass{

 public ClassONE one; //Points to an object (row) of ClassONE
 public ClassTWO two; //Points to an object (row) of classTWO.
 public Double data; //Data that need being saved with this particular relation between obj1 and obj2.

}

I know that with Hibernate you can declare a ManyToMany monodirectional relationship between class1 and class2. Class1 can have some objects of class2, and class2 can be on some objects of class1. Thats just [CLASS1] N —- N [CLASS2].

I want declare a [CLASS1]1—N[INTERMEDIATECLASS]N—1[CLASS2] typical N-N database implementation. Intermediate class has an attribute very important: data, a Double type. I cannot find the way to declare IntermediateClass as my own way to implement this N–N with this data in Hibernate Annotations.

Any help, please? Just with this simple example i can solve my trouble. I didnt would make my tries on it in order to maintain clean the code for your understanding.

  • 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-27T15:27:54+00:00Added an answer on May 27, 2026 at 3:27 pm

    You can create a full blown bidirectional many-to-many mapping with an intermediate mapping class with additional properties the same way you would design your ER model:

    class A {
      private List<AB> ab;
    
      @OneToMany(mappedBy = "a")
      public List<AB> getAb() {...}
    }
    
    class B {
      private List<AB> ab;
    
      @OneToMany(mappedBy = "b")
      public List<AB> getAb() {...}
    }
    

    And the mapping class:

    class AB {
      private A a;
      private B b;
      private double data;
    
      @ManyToOne
      @JoinColumn
      public A getA() {...}
    
      @ManyToOne
      @JoinColumn      
      public B getB() {...}
    
      @Column
      public double getData() {...}
    }
    

    But since bidirectional associations like this can get rather messy and hard to maintain in your application code I would do without the bidirectional association and just define the two unidirectional many-to-one associations in class AB.

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

Sidebar

Related Questions

Basically the situation is like this (simplified, pseudo code): I have 2 TABLES person
I have an unavoidable situation that looks like this (simplified): FUNCTION_TO_CALL = y #
I have following situation (simplified, of course): MyDomain.groovy: class MyDomain { MyAnotherDomain anotherDomain //
Is there any advanced Oracle SQL methods to solve this kind of situation? Simplified:
When I have a method like this: public static void foo(String param) throws IOException
Hey. I've got a dumb, but nasty problem. If I've got this (simplified) situation:
The situation is like this: there is a continuous loop, that updates some values.
Given this simplified data format: <a> <b> <c>C1</c> <d>D1</d> <e>E1</e> <f>don't select this one</f>
Disclaimer: This is not homework. Also, I'm describing a simplified situation so bear with
Problem (simplified to make things clearer): 1. there is one statically-linked static.lib that 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.