Grails/GORM question regarding missing method

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails/GORM question regarding missing method

Robert Stagner
All,

I'm new to Grails and have been experimenting with attempting to reverse engineer some tables from a legacy database (I've been using the db-reverse-engineer plugin).  When I attempt to run the following code against the domain classes that have been generated

def license = new License()
def myArtist = new Artist()
myArtist.with {
name = "Tester Jester"
typeId = 2
setupById = "stagr005"
setupDate = new Date()
}
license.with {
project = "Test Oh Sweet Test"
projectTypeId = 2 // Trailer
fee = new BigDecimal("35000.00")
feeCurrencyId = 153 // US Dollars
licenseeId = 661 // Paramount
contractDate = new Date() - 10
licenseStatusId = '1' // License is in-progress
licenseTermId = 'P' // perpetual
setupById = 'stagr005'
setupDate = new Date()
// licenseProductId -- what is this for????
artist = myArtist
territory = new Territory()
}
myArtist.addToLicenses(license)
myArtist.save(failOnError: true)

I get the following error

Caught: groovy.lang.MissingMethodException: No signature of method: Artist.addToLicenses() is applicable for argument types: (License) values: [License : (unsaved)]

Please see the following Gist for the complete Groovy script and a list of the domain classes: https://gist.github.com/restagner/0e8644ad1955d839b19f

I was under the impression that I could use the addTo* style methods to add certain domain objects.  I'm sure that  I'm overlooking something obvious here, but I just can't quite figure it out.  I have reviewed the Grails documentation, but could not pick up on where I'm going wrong


--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/1336e457-dc07-466a-95b8-a2895df1b190%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Grails/GORM question regarding missing method

bobbywarner
Please ask usage questions on StackOverflow.

To answer your question though, you need to correctly define the relationships in your domain classes (hasMany / belongsTo) in order to use addTo methods.  Hope that helps!


Thanks,
Bobby

On Wednesday, March 11, 2015 at 3:58:09 PM UTC-5, Robert Stagner wrote:
All,

I'm new to Grails and have been experimenting with attempting to reverse engineer some tables from a legacy database (I've been using the db-reverse-engineer plugin).  When I attempt to run the following code against the domain classes that have been generated

def license = new License()
def myArtist = new Artist()
myArtist.with {
name = "Tester Jester"
typeId = 2
setupById = "stagr005"
setupDate = new Date()
}
license.with {
project = "Test Oh Sweet Test"
projectTypeId = 2 // Trailer
fee = new BigDecimal("35000.00")
feeCurrencyId = 153 // US Dollars
licenseeId = 661 // Paramount
contractDate = new Date() - 10
licenseStatusId = '1' // License is in-progress
licenseTermId = 'P' // perpetual
setupById = 'stagr005'
setupDate = new Date()
// licenseProductId -- what is this for????
artist = myArtist
territory = new Territory()
}
myArtist.addToLicenses(license)
myArtist.save(failOnError: true)

I get the following error

Caught: groovy.lang.MissingMethodException: No signature of method: Artist.addToLicenses() is applicable for argument types: (License) values: [License : (unsaved)]

Please see the following Gist for the complete Groovy script and a list of the domain classes: <a href="https://gist.github.com/restagner/0e8644ad1955d839b19f" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Frestagner%2F0e8644ad1955d839b19f\46sa\75D\46sntz\0751\46usg\75AFQjCNFJHCxTfUn1EDNbFN99Et3vA60JJA';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Frestagner%2F0e8644ad1955d839b19f\46sa\75D\46sntz\0751\46usg\75AFQjCNFJHCxTfUn1EDNbFN99Et3vA60JJA';return true;">https://gist.github.com/restagner/0e8644ad1955d839b19f

I was under the impression that I could use the addTo* style methods to add certain domain objects.  I'm sure that  I'm overlooking something obvious here, but I just can't quite figure it out.  I have reviewed the Grails documentation, but could not pick up on where I'm going wrong


--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/5b4acb6c-6216-4788-8671-b56c8aa14333%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Grails/GORM question regarding missing method

Robert Stagner
Ok, thanks.

On Wednesday, March 11, 2015 at 2:15:22 PM UTC-7, Bobby Warner wrote:
Please ask usage questions on StackOverflow.

To answer your question though, you need to correctly define the relationships in your domain classes (hasMany / belongsTo) in order to use addTo methods.  Hope that helps!


Thanks,
Bobby

On Wednesday, March 11, 2015 at 3:58:09 PM UTC-5, Robert Stagner wrote:
All,

I'm new to Grails and have been experimenting with attempting to reverse engineer some tables from a legacy database (I've been using the db-reverse-engineer plugin).  When I attempt to run the following code against the domain classes that have been generated

def license = new License()
def myArtist = new Artist()
myArtist.with {
name = "Tester Jester"
typeId = 2
setupById = "stagr005"
setupDate = new Date()
}
license.with {
project = "Test Oh Sweet Test"
projectTypeId = 2 // Trailer
fee = new BigDecimal("35000.00")
feeCurrencyId = 153 // US Dollars
licenseeId = 661 // Paramount
contractDate = new Date() - 10
licenseStatusId = '1' // License is in-progress
licenseTermId = 'P' // perpetual
setupById = 'stagr005'
setupDate = new Date()
// licenseProductId -- what is this for????
artist = myArtist
territory = new Territory()
}
myArtist.addToLicenses(license)
myArtist.save(failOnError: true)

I get the following error

Caught: groovy.lang.MissingMethodException: No signature of method: Artist.addToLicenses() is applicable for argument types: (License) values: [License : (unsaved)]

Please see the following Gist for the complete Groovy script and a list of the domain classes: <a href="https://gist.github.com/restagner/0e8644ad1955d839b19f" rel="nofollow" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Frestagner%2F0e8644ad1955d839b19f\46sa\75D\46sntz\0751\46usg\75AFQjCNFJHCxTfUn1EDNbFN99Et3vA60JJA';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Frestagner%2F0e8644ad1955d839b19f\46sa\75D\46sntz\0751\46usg\75AFQjCNFJHCxTfUn1EDNbFN99Et3vA60JJA';return true;">https://gist.github.com/restagner/0e8644ad1955d839b19f

I was under the impression that I could use the addTo* style methods to add certain domain objects.  I'm sure that  I'm overlooking something obvious here, but I just can't quite figure it out.  I have reviewed the Grails documentation, but could not pick up on where I'm going wrong


--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/f83546a4-6caf-49bc-9d52-53e6326fb3d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.