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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:35:48+00:00 2026-05-25T14:35:48+00:00

A very simplified example of how I use createCriteria method for getting data in

  • 0

A very simplified example of how I use createCriteria method for getting data in my Grails application:

    def c = SomeClassOfMine.createCriteria()
    def projects = c.list(max: limit, offset: start) {
        eq("userId", userId)
        if (owner != null && owner.size() > 0) {
            ilike("ownerName", owner + "%")
        }
        if (someParameter && someParameter.size() > 0) {
            or {
                ne("validated", 1)
                ne("validated2", 1)
            }
        }
        order("name", "asc")
    }

On the line having or { I get NullPointerException without message. I have tried various combinations and followed closely the examples given in various places only to find that I get the same problem if I try to use and too. I know that there are other ways to get the data, but I would very much like to use this approach. I failed to figure out what might be wrong by myself so… What might cause NullPointerException in such code block on or / and?

I would provide more information if I would know what is relevant in this case.


EDIT: Added an if clause (where owner is checked) to code example.

I have investigated more and find out that the problem is in if (owner != null && owner.size() > 0) { and to be more specific, the variable name owner. When I change the name to anything else the problem is gone. It would be very interesting if someone could explain why this is happening.

  • 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-25T14:35:49+00:00Added an answer on May 25, 2026 at 2:35 pm

    The issue is “owner” is a reserved word in Groovy. This is described in Groovy Closures.
    You can try placing single quotes around ‘owner’ so that your line of code would read:

    if (‘owner’ != null && ‘owner’.size() > 0) {

    That may work. Your best option is to use a new variable name to avoid any confusion.

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

Sidebar

Related Questions

I have a linq to sql database. Very simplified we have 3 tables, Projects
The following example is a very simplified version of my top navigation. http://jsfiddle.net/AEqxT/ If
Here's my proposed (very simplified to illustrate the problem space) design for a C#
This is a (very) simplified version of my iPhone code : @interface x {
I need to quickly build a parser for a very simplified version of a
I'm using a MySQL database to store scores for my game. A very simplified
This is a simplified example, but I am working on a code translator that
I am developing an application which displays multiple views as tables (for example customers,
I was trying to find an example about how to use TryScan , but
Im trying to mock a new File generated in a loop. Simplified example: class

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.