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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:07:07+00:00 2026-06-07T10:07:07+00:00

I have legacy Database Schema (PostgreSQL) I cant change it. I’m having problems mapping

  • 0

I have legacy Database Schema (PostgreSQL) I cant change it. I’m having problems mapping my class with a database model, this is what I want and what I have:

-> Database Schema – DataTable Users – PostgreSQL

PK id STRING (email), password STRING

-> My model – Domain Users

PK email STRING, password STRING

I need be able to let to the users insert via the create.gsp view the id (email) of the user, i dont want to change manually the create.gsp or other .gsp I want Grails auto-generate the views for me.

So, How can i do to auto-generate the views showing the primary key like other field to let final user insert/see it?

In my Domain I have something like this:

class Usuario {
    String id
    String password

    static constraints = {
        id email: true
        password blank:false, nullable:false
    }

    static mapping = {
        table 'usuario'
        version false
        id column: 'id', generator: 'assigned'
    }

    String toString(){
        return id
    }
}

Thanks in advance, and sorry about my english!

UPDATE:

I just try to insert [the following piece of code] into my user controller and now i can see the id field, but only when I create a new user create.gsp, when I show list of users in the list.gsp I cant see the field id (email)

def scaffold = Usuario 

UPDATE II:

I have followed the comment from user1128791 and it worked for me, I install the templates system and then I worked over it, changing list.gsp form src/templates/scaffolding to show the id field, something like this:

excludedProps = Event.allEvents.toList() << 'version' << 'id'
allowedNames = domainClass.persistentProperties*.name << 'dateCreated' << 'lastUpdated'

for this

excludedProps = Event.allEvents.toList() << 'version'
allowedNames = domainClass.persistentProperties*.name << 'dateCreated' << 'lastUpdated' << 'id'

UPDATE III:

I’ve gone further and made ​​the following changes, to work only with my email field and password field.

class User {
    String email
    String password

    static transients = ['id']

    void setId(String email) {
       id = email
    }

    String getId() {
       return email
   }

   static constraints = {
       email email: true, blank:false, nullable:false
       password blank:false, nullable:false
   }
    static mapping = {
        table 'usuario'
        version false
        id generator: 'assigned', name: 'email'
        email column: 'id'
    }

    String toString(){
        return id
    }
}

To enable you to have the maximum amount of information about my problem and how i solved it, thats what i’m mapping:

CREATE TABLE usuario
(
   id text NOT NULL,
   "password" text,
    CONSTRAINT "PK usuario" PRIMARY KEY (id)
);
  • 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-07T10:07:08+00:00Added an answer on June 7, 2026 at 10:07 am

    From http://www.grails.org/Artifact+and+Scaffolding+Templates:

    To customize the templates for you project you need to the install the templates:

    grails install-templates
    

    This will create the src/templates folder in your project which will contain various artifact and scaffolding templates.

    Than you will have to change each *.gsp template to render a textfield instead of hidden field for ID’s.

    EDIT: Looking into the templates. Grails 2.0 should do this automaticaly for ‘assigned’ id’s.

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

Sidebar

Related Questions

I want to access a legacy database schema from Rails. I have one table
I have a legacy database set with NLS_LANG set to IW8ISO8859P8. This I cannot
I am trying to map a new domain model to a fixed-schema legacy database
So, my problem is this. I have a legacy MySQL database that I'm building
I am working with a legacy database schema that looks like this: product_table table
I have to map a large enterprise database schema. As a number of legacy
Being stuck with a legacy database schema that no longer reflects your data model
I am using NHibernate's SchemaExport to create my database schema. I have 1 legacy
I have a legacy SQL schema which looks something like this: CREATE TABLE `User`
I have a legacy database with 3 tables like this: (source: bilder-hochladen.net ) 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.