I am trying to add data to a database, in grails but get this error:
Error 500: Executing action [getData] of controller [mgr.CollectDataEntryController] caused exception: groovy.lang.MissingMethodException: No signature of method: static groovy.lang.MissingMethodException.addToAlumConnectionEducations() is applicable for argument types: (mgr.AlumConnectionEducations) values: [mgr.AlumConnectionEducations : null]
where CollectDataEntryController is the controller doing the work. here is the code snippet from that controller:
saveNewAlum.addToAlumConnectionEducations(new AlumConnectionEducations(alumConnectionsId:connectionId, degree:alumConnectionEduDegree,endDate:alumConnectionEduEndDate,fieldOfStdudy:alumConnectionEduFieldOfStudy,schoolName:alumConnectionEduSchoolName,startDate:alumConnectionEduStartDate))
the domain, AlumConnectionEducations , belongs to a one to many relationship with another domain, AlumConnections, which in turn belongs to a one-to-many relationship with to another domain, alumProfile
to, in my code I first add the domain AlumConnection, which works fine but when i then try to add AlumConnectionEducations i get the above error. anyone have any idea of what i am doing wrong?
thanks jason
package mgr
import java.util.Date;
class AlumConnections {
String linkedinId
String firstName
String lastName
String headline
String locationName
String locationCode
String industry
Date dateCreated
Date lastUpdated
long version
static belongsTo = [alumProfile:AlumProfile]
static hasMany = [
alumConnectionEducations : AlumConnectionEducations
]
static mapping = {
cache true
columns {
linkedinId type:'text'
firstName type:'text'
lastName type:'text'
headline type:'text'
locationName type:'text'
locationCode type:'text'
industry type:'text'
}
}
static constraints = {
linkedinId (nullable:false, blank:false)
firstName (nullable:true)
lastName (nullable:true)
headline (nullable:true)
locationName (nullable:true)
locationCode (nullable:true)
industry (nullable:true)
}
}
in the controller that calls the domains:
def saveNewAlum = ""
saveNewAlum = new AlumProfile(firstName:linkedinFirstName, lastName:linkedinLastName, dob:newDate,industry:linkedinIndustry, oAuthToken:oAuthtoken, secretKey:secretKey)
saveNewAlum.addToAlumConnections(new AlumConnections(linkedinId:connectionId,firstName:connectionFName, lastName:connectionLName, headline:connectionHeadline, locationName:connectionLocationname, locationCode:connectionLocationCode,industry:connectionIndustry))
The above code works fine and saves to the MySQL database. its only when i try to create saveNewAlum.addToAlumConnectionEducations that i get the error
saveNewAlumvariable? Have you verified that it's truly an instance ofAlumConnections?