Grails

Needs "def face" with "static belongsTo = [face:Face]"

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Cannot Reproduce
  • Affects Version/s: None
  • Fix Version/s: 1.2 final
  • Component/s: Documentation
  • Labels:
    None

Description

I tried the following syntax as documented at http://grails.org/doc/1.0.x/guide/5.%20Object%20Relational%20Mapping%20(GORM).html#5.5.1%20Events%20and%20Auto%20Timestamping
Example C

class Face {
Nose nose
}
class Nose { // Missing def face static belongsTo = [face:Face] }

and I get this error:

2008-11-24 14:16:12.305::WARN: Failed startup of context org.mortbay.jetty.webapp.WebAppContext@6bc5aa{/bindertest,C:\GrailsWork\bindertest/web-app}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exceptio
n is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'se
ssionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creatin
g bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for:
Top, at table: child, for columns: [org.hibernate.mapping.Column(top)]
at java.security.AccessController.doPrivileged(Native Method)
at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy:69)
at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy)
at Init_groovy$_run_closure6.doCall(Init_groovy:131)
at RunApp_groovy$_run_closure2.doCall(RunApp_groovy:68)
at RunApp_groovy$_run_closure2.doCall(RunApp_groovy)
at RunApp_groovy$_run_closure1.doCall(RunApp_groovy:60)
at RunApp_groovy$_run_closure1.doCall(RunApp_groovy)
at gant.Gant.dispatch(Gant.groovy:271)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.processTargets(Gant.groovy:436)
at gant.Gant.processArgs(Gant.groovy:372)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to be
an 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error c
reating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine typ
e for: Top, at table: child, for columns: [org.hibernate.mapping.Column(top)]
at java.security.AccessController.doPrivileged(Native Method)
... 13 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed;
nested exception is org.hibernate.MappingException: Could not determine type for: Top, at table: child, for columns: [org.hibernate.mapping.Column(top
)]
at java.security.AccessController.doPrivileged(Native Method)

I changed the syntax to:

static belongsTo = Face

as indicated a bit further down:

You could keep the previous relationship as unidirectional and allow saves/updates to cascade down by doing the following:

class Face {
Nose nose
}
class Nose {
static belongsTo = Face

}

and everything runs fine.

It seems that I needed

def face

to be able to use the

static belongsTo= [face: Face]

syntax

Without the "def face" I need to use "belongsTo: Face"

Activity

Hide
Fred Janon added a comment -

Using 1.0.3

Show
Fred Janon added a comment - Using 1.0.3
Hide
Graeme Rocher added a comment -

Assigning all documentation related issues to 1.2 final since they don't represent a change to the codebase

Show
Graeme Rocher added a comment - Assigning all documentation related issues to 1.2 final since they don't represent a change to the codebase
Hide
Graeme Rocher added a comment -

seems the documentation has already been fixed for this

Show
Graeme Rocher added a comment - seems the documentation has already been fixed for this

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: