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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:57:05+00:00 2026-05-27T19:57:05+00:00

I am having a domain class arHistory as follows: package ars import ars.AccessRequest import

  • 0

I am having a domain class arHistory as follows:

package ars
import ars.AccessRequest
import gra.Users
class ArHistory {
    Long id =2340
    Users updatedby
    Date updatedon
    String requeststatus  
    static hasMany=[accessrequests:AccessRequest]

    static constraints = {
         requeststatus(blank:false, nullable:false)
    }

Now after I run the application the GORM create tables ar_history and ar_history_access_request (the join table for one to many relationship)

The join table above has only 2 foreign keys, the table itself has no primary key id
I wanted to know 3 things,
1) do I need to have a primary key id for the join table
2) if yes how do I create the id (do I create it manually through mysql)
3) whats the advantage of having hasMany() instead of having a class variable AccessRequest defined in ArHistory, is it just normalised data?

Regards
Priyank

  • 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-27T19:57:05+00:00Added an answer on May 27, 2026 at 7:57 pm

    You don’t need primary key in join table, since you don’t allow duplicates with hasMany. Read the documentation of hasMany: “Grails will automatically inject a property of type java.util.Set into the domain class based on the hasMany setting”. Thus, primary key is not needed.

    What do you mean by third question? hasMany allows you to add many AccessRequest objects to a collection.

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

Sidebar

Related Questions

Having problems with domain class mappings. The domains are as follows: User Domain class
When designing both the domain-model and class-diagrams I am having some trouble understanding what
Having a grails domain class, how to find the type of a property having
I am using Grails 1.3.7, and have the following domain classes: package com.fxpal.test class
Having the following domain class: class Message{ } Want to get all messages with
I have the following domain class: class Car{ int hp Date registrationDate } Now
I have seen on the web some domain names having prefix of ww2 or
I'm having trouble getting my domain pointed to my website hosted with google app
I'm having a hard time convincing our architect that a Domain model should only
Having trouble with Grails Domain Classes. I am overriding the constructor to build the

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.