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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:12:30+00:00 2026-06-08T20:12:30+00:00

Can someone help me with my situation. I have the following code. class Employee

  • 0

Can someone help me with my situation. I have the following code.

class Employee {

    Integer empId
    String firstName
    String lastName

    static constraints = {
        empId()
        firstName()
        lastName()
    }

    static mapping = {
        id generator:'assigned', name:'empId'
        version false
    }
}

The code allows me to save employee through ‘create’ but gives the following error message

“Employee not found with id null” and also in the list, all the employees are listed but clicking on any Emp Id gives the same error. Please help. This is driving me nuts.

Rocky


Thanks for your reply. Like I mentioned I am able to save the empId in the database but get that message nonetheless and see the list with assigned ids (empId). The link points to employee/show with no number at end. However employee/show/22(empId) works fine. employee/edit/22 works too but update does not work.

I am not using any assigned sequence. Just some random integer. Maybe a better example would be to use SSN instead of empId.

Thank you once again.


You are a great help buddy. Appreciate your time and patience. I am not writing any special update or save (I am too new to dig too deep). Just using grails to generate-all. However, I did find a workaround. I changed the domain class to add variable id (Long) and added empId setter method to allocate the empId value to id. That did it. Here is my code.

class Employee {
Long id
Long empId
String firstName
String lastName

static constraints = {
    empId()
    firstName()
    lastName()
}

static mapping = {
    id generator:'assigned', name:'empId', column: 'emp_id'
    version false
}

public void setEmpId(Long empId){
    this.empId = empId
    this.id = empId
}

}

Please feel free to suggest if you have a better way of doing that.

Regards

Rocky

  • 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-08T20:12:31+00:00Added an answer on June 8, 2026 at 8:12 pm

    If you are using the “assigned” sequence, then you have to assign the objects ids yourself before saving them. Otherwise your objects will be saved with a null or ‘default 0’ id. If you want GORM to assign an id for you, you need to use another type of generator, like “sequence” generator. It would be like:

    id name: 'customId', generator: 'sequence', params: [sequence:'some_sequence']
    

    More info on id generators here.

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

Sidebar

Related Questions

Hoping that someone can help clear up this very annoying situation I find myself
Can someone help by showing me how to sort a LINQ expression. I have
Can someone help me with creating functions for the following processes? I want to
Can someone help out with an animation issue I can't figure out. I have
I have a problem with JPA 1.0 (OpenJPA) Following situation @Entity public class A{
A lot of time I spent for this situation. maybe someone can help me?
Hopefully someone here can help me with this challenge! I have a parent page
I hope someone can help me! I have 2 activity A and B. In
I can't seem to find anything to help my situation & was hoping someone
Can someone help me achieve multiple zend pagination in a view using ajax. I

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.