Grails

Regression: toString() on domain classes is showing "SomeClassName : null" i.e. null instead of id (in log statement)

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.6
  • Fix Version/s: 1.0.5
  • Component/s: None
  • Labels:
    None

Description

When calling toString in log statement on class that inherits from parent class, "SomeClassName : null" is printed instead of "SomeClassName : 1"

grails create-app nullInToString
cd nullInToString
grails create-domain-class Person
grails create-domain-class Customer

abstract class Person {
String name
}

class Customer extends Person {
Date firstContactDate
}

grails generate-all Customer

edit CustomerController:

def show = { def customer = Customer.get( params.id ) log.info("returning customer: $customer") [ customer : customer ] }

Bootstrap:
def init = { servletContext -> new Customer (name:"mike", firstContactDate:new Date()).save() }

grails run-app

log output:
2007-09-24 09:17:54.233::INFO: Started SelectChannelConnector@0.0.0.0:8080
Server running. Browse to http://localhost:8080/nullInToString
[9575] controller.CustomerController returning customer: Person : null

Notice the log statement shows Person: null instead of Person: 1

Issue Links

Activity

Hide
Mike Hugo added a comment -
Show
Mike Hugo added a comment - this could be related to http://jira.codehaus.org/browse/GRAILS-1313
Hide
Lee Butts added a comment -

Fixed. Test project now outputs Customer : 1 instead of Person : null

Show
Lee Butts added a comment - Fixed. Test project now outputs Customer : 1 instead of Person : null
Hide
Peter Ledbrook added a comment -

Fixing this issue has reintroduced GRAILS-1165. Re-opening both of them.

Show
Peter Ledbrook added a comment - Fixing this issue has reintroduced GRAILS-1165. Re-opening both of them.
Hide
Lee Butts added a comment -

Moved all injected property/method tests into one place (DomainClassGrailsPluginTests) and moved injection to a later compile phase which gives correct information when calling classNode.getMethods and getProperties etc.

Show
Lee Butts added a comment - Moved all injected property/method tests into one place (DomainClassGrailsPluginTests) and moved injection to a later compile phase which gives correct information when calling classNode.getMethods and getProperties etc.

People

Vote (2)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: