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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:49:41+00:00 2026-06-01T02:49:41+00:00

I have many domain classes in my application an for Audit logging I need

  • 0

I have many domain classes in my application an for Audit logging I need the name attribute of each Domain class. unfortunately the name attribute is not generic in all Domains.
In my Audt log class I get the type of object modified/created/deleted and then save the id right now (which is common code since all domains have ‘id’ attribute) but now if I want to get the name attribute out of the domain from the ID, each domain has a different name attribute, like Resource Domain has resourceName, User domain has userName and so on… soI will have to handle each domain seperately (like have a map or bunch of switch statements for getting the name attribute from the Domain class name).
Is there a way I can have an alias mapping for each domain class’s name field to be called ‘name’ . there should not be any change to the actual attributes in the Domains in whatever changes I do, I can add a column to Audit Domain but not other table changes.
Thanks in Advance

  • 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-01T02:49:42+00:00Added an answer on June 1, 2026 at 2:49 am

    I don’t think that there’s any way to do this automatically.

    As you guessed, you’re going to either have to change all of the domain objects so that they have a ‘name’ attribute, or somehow maintain a map of which attribute in each class is to be considered the ‘name’.

    I suppose that one answer might be to add a getName() method to each of the domain classes, and return the appropriate value from that method.

    If you really don’t want to modify the domain objects at all, you can use groovy meta-object programming (MOP) to inject this method into each domain class from the BootStrap class.

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

Sidebar

Related Questions

I have two classes in Grails application , Employee has hasMany(one To Many relations)
I have a problem with one-to-many relationships. I have the following domain classes: public
I have two domain classes with a many-2-many relationship between them, e.g. User and
I have 2 domain classes which are mapped by many-to-many relationship. I followed the
I have two basic domain classes: public class Event { private Long id; private
My domain classes that have one-to-many mappings generally take the following form (untested code):
I was surprised to learn that a single domain name can have many IP
In my application I have a strong requirement for logging each event for the
I have two domain classes: User : class User { String login String password
I have the following domain classes: Holiday : class Holiday { String justification User

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.