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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:48:42+00:00 2026-05-26T11:48:42+00:00

So I have 2 classes that have a many to many association. When the

  • 0

So I have 2 classes that have a many to many association. When the database gets generated I get 2 join tables: user_link_sections and link_section_users. The first I expected, but am not sure why the 2nd join table was generated. Grails is only using the first as well. I’m a noobie to groovy/grails, but tried following the documentation to set this up right. Any help is appreciated!

Here are my domain class declarations…

class User {

    transient springSecurityService

    // Custom Attributes
    String firstName
    String lastName
    String email
    String company
    String phone
    Date dateCreated
    Date lastUpdated

    static hasMany = [linkSections: LinkSection]

    String username
    String password
    boolean enabled
    boolean accountExpired
    boolean accountLocked
    boolean passwordExpired
}

and

class LinkSection {

    String name
    String description
    Date dateCreated
    Date lastUpdated

    List links = new ArrayList()

    static belongsTo = User
    static hasMany = [links: Link, users: User]

    static constraints = {
    name blank: false
    description(maxSize: 10000)
    }

    static mapping = {
    links cascade: "all,delete-orphan"
    }
}
  • 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-26T11:48:43+00:00Added an answer on May 26, 2026 at 11:48 am

    Try setting the owning side of the many-many:

    static belongsTo = User
    

    this goes on the LinkSection. Remember only one side knows to persist the relationship.

    The other thing to do is to make sure and clear out the tables that may have been left over from your previous attempts at mapping…just to be sure.

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

Sidebar

Related Questions

I have a many-to-many relationship between 2 tables that I define with a join
Basically, I have a model where I've created a superclass that many other classes
I have an ASP.NET project that contains many classes. I am thinking about creating
I have a abstract base class that I have many inherited classes coming off
I have many structs (classes) and standalone functions that I like to compile separately
I have the following query with many LEFT JOIN clauses that has 7 result
I have two classes A and B. Many B's can have association with a
I have many classes that implements IBuilder<> interface such the ones below UPDATED: each
I have two C# classes that have many of the same properties (by name
Database structure I have two classes, A and B, that have two different relationships:

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.