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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:15:12+00:00 2026-05-29T08:15:12+00:00

I am trying to learn Hibernate and i can’t solve a design problem. I

  • 0

I am trying to learn Hibernate and i can’t solve a design problem.
I have Head and Group Classes. I have generated two tables listed below using hibernate.

Table-Head
id, int4, primary key
name, varchar 50
description, varchar 250

Table-Group 
id, int4, primary key
name, varchar 25
description, varchar 250

I just want to ask how can i generate HeadAndGroup table which is listed below? I have tried to write HeadAndGroup as separate class but i can’t handle it.

Table HeadAndGroup (Many to Many)
id , int4, primary key
head_id , int4, foreign key -> head table
group_id , int4, foreign key -> group table


**head_id, group_id pair will be unique
  • 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-29T08:15:13+00:00Added an answer on May 29, 2026 at 8:15 am

    You can add a Collection<Head> heads in your Group class with @ManyToMany annotation. Hibernate will then handle the HeadAndGroup table for you.

    @ManyToMany(
        targetEntity=Head.class,
        cascade={CascadeType.PERSIST, CascadeType.MERGE}
    )
    public Collection getHeads() {
        return heads;
    }
    

    Have a look here for details.

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

Sidebar

Related Questions

trying to learn and practice arrays but I have a problem with this small
Trying to learn about php's arrays today. I have a set of arrays like
In trying to learn how to create objects in ActionScript, I have had no
I am trying to learn Spring and Hibernate and i am really struggling to
I am trying to learn JPA with Hibernate and binding it to a GUI
i am trying to learn Java, Hibernate and the MVC pattern. Following various tutorial
i'm trying to learn Grails console and had a problem. It looks like this:
Trying to learn PL/SQL with multimedia data. Can anyone please point out that from
I'm trying to learn Spring+Hibernate and I started using Lazy loading with Hibernate. To
I'm trying to learn NHibernate, and I've stumbled into a combined database design /

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.