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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:52:27+00:00 2026-05-16T11:52:27+00:00

I have 2 domains : class JobProcess { static constraints = { scriptUser(blank:false) scriptType()

  • 0

I have 2 domains :

class JobProcess {

    static constraints = {
       scriptUser(blank:false)
       scriptType()
       scriptName()
       scriptPath()
       scriptArgs(size:0..1000,nullable:true)
       scriptDateCreated(nullable:true)
       scriptDateStarted(nullable:true)
       scriptDateFinished(nullable:true)
       scriptRun()
       scriptId()
    }

    static mapping = {
      version false
    }
    User scriptUser  
    String scriptType
    String scriptName
    String scriptPath
    String scriptArgs
    Date scriptDateCreated
    Date scriptDateStarted
    Date scriptDateFinished
    String scriptRun
    int scriptId
}

and :

class User {

  static hasMany = [ jobs : JobProcess ]

    static constraints = {
        login(unique: true, blank: false)
        password(password: true, blank: false)
        email(blank: false, emailAddr: true, maxSize: 50)
        firstName(blank:false, maxSize:32)
        lastName(blank:false, maxSize:32)
        phoneNo(nullable: true)
    }

    static mapping = {
        sort lastName: 'asc'
    }

    String login
    String firstName
    String lastName
    String phoneNo
    String email
    String password

    boolean locked = false

    String toString()
    {
        if (firstName == "")
            return email
        return fullName()
    }

    String fullName()
    {
        return firstName + " " + lastName
    }
}

And this query :

selected = JobProcess.withCriteria{
      like("scriptUser", "%${params.name}%")
      maxResults(params.max as int)
      firstResult(params.offset? params.offset.toInteger():0)
      }

I get errors :

ERROR property.BasicPropertyAccessor  - IllegalArgumentException in class: common.User, getter method of property: id      
ERROR errors.GrailsExceptionResolver  - java.lang.ClassCastException@503ca729

I also try by replacing like part by :
eq("scriptUser", 1) but I get same errors.

What’s wrong ? Any ideas ?

  • 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-16T11:52:28+00:00Added an answer on May 16, 2026 at 11:52 am

    If params.name is the User‘s firstName, try this:

    JobProcess.withCriteria {
        scriptUser {
            like('firstName', "%${params.name}%")
        }
        maxResults(params.max as int)
        firstResult(params.offset ? params.offset.toInteger() : 0)
    }
    

    If params.name is something different, can you clarify your question to explain how you’re using it?

    Here’s proof of concept code:

    // grails-app/domain/JobProcess.groovy
    class JobProcess {
        User scriptUser
    }
    
    // grails-app/domain/User.groovy
    class User {
        String name
    }
    
    // grails-app/conf/Bootstrap.groovy
    def init = { servletContext ->
        def foo = new User(name: 'foo').save()
        def bar = new User(name: 'bar').save()
        new JobProcess(scriptUser: foo).save()
        new JobProcess(scriptUser: bar).save()
        new JobProcess(scriptUser: bar).save()
    
        def result = JobProcess.withCriteria {
            scriptUser {
                like('name', 'ba%')
            }
        }
        result.each {
            println "Result ID: ${it.id}"
        }
    
        // prints:
        // Result ID: 2
        // Result ID: 3
     }
    

    This is based on the “Querying Associations” section here.

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

Sidebar

Related Questions

I have two domains : class CodeSetDetail { String id String codeSummaryId static hasMany
I have two simple domains: public class Hotel { static searchable = true Source
I'm not very good in SQL and HQL... I have two domains: class Hotel
I have two domains declared in my app. class Posts { String title String
I have a domain class: class Author { String name static hasMany = [superFantasticAndAwesomeBooks:
I have the following model class DNS(models.Model): domain = models.ForeignKey(Domain) host_start = models.CharField(max_length=150, blank=True,
I've got a class called Domain. Each Domain can have multiple sub-domains (of the
I have two following domains: User { UserData userData } UserData { static belongsTo
I have a class called Domains with properties - domain, user, start date, due
I'm working with Symfony2 and Doctrine2 and I have a class called Domains with

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.