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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:15:33+00:00 2026-05-22T16:15:33+00:00

In my application I have a User domain object that has a handful of

  • 0

In my application I have a User domain object that has a handful of fields in it including a password field. The password field is an encrypted String using JASYPT. For development purposes I am creating a new user on startup that is hard coded. It looks like this:

User user = new User(
    userId:"user1", userFname:"Joe", 
    userLname:"Blow", userMinit:"A",
    userEmail:"joe@blow.com", userPword:"password").save()

When the save() is called I believe that in the background the hibernate saveOrUpdate() is being called. It is comparing the new domain objects field values against already existing domain object field values to decide if the record should be inserted into the db or if it should just update an already existing record.

Since the password field is always going to be a new value because of the JASYPT encryption it is inserting a new record every time.

INSERT INTO USER VALUES(1,'joe@blow.com',
    'Joe','user1','Blow','A','','','',
    'gIkUvM9b6d5vrEhkKzqKz0U7uxqRpZFhiQrrBTDbKX0=')
INSERT INTO USER VALUES(2,'joe@blow.com',
    'Joe','user1','Blow','A','','','',
    'yap0S0mCb2CpGngcANpSWoLqlL6SozLYK4WbKYHSVEw=')

Here is the Domain class:

@Table(name="user")
class User {

    String userId
    String userFname
    String userLname
    String userMinit
    String userEmail
    String userPword
    String userMisc1 = ""
    String userMisc2 = ""
    String userMisc3 = ""

    public User(){};

    static mapping = {
        version false
        columns {
            userId      column:'user_id'
            userFname   column:'user_fname'
            userLname   column:'user_lname'
            userMinit   column:'user_minit'
            userEmail   column:'user_email'
            userPword   column:'user_pword'
            userMisc1   column:'user_misc1'
            userMisc2   column:'user_misc2'
            userMisc3   column:'user_misc3'
        }

        userPword type: GormEncryptedStringType
     }

    static constraints = {}
}

Is there a way to tell GORM to ignore the password field when saving the domain object so I don’t end up with the same user over and over in the DB?

Thanks for any help.

  • 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-22T16:15:34+00:00Added an answer on May 22, 2026 at 4:15 pm

    Before saving new user, you can check if that user already exists:

    User user = User.findByUserId("user1") ?: new User(userId:"user1", userFname:"Joe",
                                                    userLname:"Blow", userMinit:"A", 
                                                    userEmail:"joe@blow.com",
                                                    userPword:"password").save(flush: true)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user of my application that sometimes when they run the application
In my application I have a class which has properties of user-defined types like
For example: I have a User which has 10 Widgets. Along with that I
Please help me about this issue... In my application i have calender where user
I have two user types in my application: Investors and Advisors , they both
I have a user control in my wp7 application which contains two text boxes
My application will have a per machine (not per user) Startup shortcut. I can
in my application i have an form where user enter their username first .
In my application I have large area (≈5000x5000pts) and I must allow user to
Currently on my application I have a form where I ask the user to

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.