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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:00:58+00:00 2026-05-18T10:00:58+00:00

preface note: I’m just starting to learn Grails, so I’m sure there are many

  • 0

preface note: I’m just starting to learn Grails, so I’m sure there are many other problems and room for optimization.

I’ve got two domains, a parent (Collection) and child (Event), in a one-to-many mapping. I’m trying to code an integration test for the deletion of children. Prior to the code in question, I’ve successfully created a parent and three children. The point where I’m having problems is getting a single child in preparation to delete it. The first line of my sample code is only there because of my rudimentary attempt to troubleshoot.

// lines 95-100 of my EventIntegrationTests.groovy file
// delete a single event
assertEquals("2nd Event", event2.title)     // passes
def foundEvent = Event.get(event2.id)       // no apparent problems
assertEquals("2nd Event", foundEvent.title) // FAILS (line #98)
foundEvent.delete()
assertFalse Event.exists(foundEvent.id)

The error message I’m getting is:

 Cannot get property 'title' on null object 

 java.lang.NullPointerException: Cannot get property 'title' on null object
         at edu.learninggrails.EventIntegrationTests.testEventsDelete(EventIntegrationTests.groovy:98)

What should my next troubleshooting steps be? (Since the first assertEquals passes, event2 is clearly not null, so at this point I have no idea how to troubleshoot the failure of the second assertEquals.)

  • 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-18T10:00:59+00:00Added an answer on May 18, 2026 at 10:00 am

    This is not evident from the code: did you persist event2 by calling save()? Get will try to retrieve it from the persistent storage (the in-memory database for example) and if the event wasn’t saved, the retrieved instance will be null.

    If you did save it, did the save go through OK? Calling event.save() will return false if there was something wrong while saving the item (like a validation error). Lastly, you might try calling event.save(flush:true) in case the Hibernate session doesn’t handle this case as you might expect (I’m not entirely sure about this one, but it can’t hurt to try).

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

Sidebar

Related Questions

Just to preface: I work in a small company that does ASP.NET development and
Preface : I'm honestly not sure if this should be on StackOverflow, SuperUser or
To preface I am using Borland C++ and the VCL. I need some sort
Let me preface this question by saying I use TextMate on Mac OSX for
I will preface this question by saying, I do not think it is solvable.
Let me preface this by saying I'm a complete amateur when it comes to
I'll preface this by saying that I usually work in C#/.Net. Normally, I use
I should preface this by saying I'm working on a pocket PC app and
I have to preface this with the fact that I love jQuery as a
I'll preface this question by saying this is for a Microsoft only shop. If

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.