I get the following error when I try to save a domain class, in grails:
No signature of method: java.lang.String.save() is applicable for argument types: () values: [] Possible solutions: size(), size(), take(int), wait(), any(), wait(long). Stacktrace follows:
I have a service that pareses an XML string into domain objects. I then try to save the domain and get that error. I've debugged and know that all the data is valid. Here is my code:
def newProfile="";
newProfile = new LinkedinProfile(
firstName : "${linkedinProfileFeed.'first-name'}",
lastName : "${linkedinProfileFeed.'last-name'}",
dobYear : "${linkedinProfileFeed.'date-of-birth'.'year'}",
dobMonth : "${linkedinProfileFeed.'date-of-birth'.'month'}",
dobDay : "${linkedinProfileFeed.'date-of-birth'.'day'}" ,
imgUrl : "${linkedinProfileFeed.'picture-url'}",
siteStandardAddress : "${linkedinProfileFeed.'site-standard-profile-request'}",
oAuthToken : accessTokenKey.toString(),
secretKey : accessTokenSecret.toString()
)
.id="${linkedinProfileFeed.id}".toString()
log.debug("${linkedinProfileFeed.id}".toString())
log.debug("${linkedinProfileFeed.'first-name'}")
log.debug("${linkedinProfileFeed.'last-name'}")
log.debug("${linkedinProfileFeed.'date-of-birth'.'year'}")
log.debug("${linkedinProfileFeed.'date-of-birth'.'month'}")
log.debug("${linkedinProfileFeed.'date-of-birth'.'day'}")
log.debug("${linkedinProfileFeed.'picture-url'}")
log.debug("${linkedinProfileFeed.'site-standard-profile-request'}")
log.debug(accessTokenKey.toString())
log.debug(accessTokenSecret.toString())
log.debug("end debug")
newProfile.save();
Also, I'm not to familiar with grails and springsource, but in .Net, I can access an objects properties using the dot operator. For example, if I had an object as described above, I could just type newProfile. and would have access to all the properties. In grails this doesnt happen. is this by design or an error in my code?
below is my domain class, as well.
class LinkedinProfile {
String firstName
String lastName
String dobYear
String dobMonth
String dobDay
String oAuthToken
String secretKey
String id
String imgUrl
String siteStandardAddress
Date dateCreated
Date lastUpdated
long version
static hasMany = [
linkedinLocation : LinkedinLocation,
linkedinSkill : LinkedinSkill
]
static mapping = {
cache true
id generator: 'assigned'
columns {
firstName type:'text'
lastName type:'text'
oAuthToken type:'text'
secretKey type:'text'
dobYear type:'text'
dobMonth type:'text'
dobDay type:'text'
imgUrl type:'text'
siteStandardAddress type:'text'
}
}
static constraints = {
firstName (nullable:true)
lastName (nullable:true)
oAuthToken (nullable:false)
secretKey (nullable:false)
dobYear (nullable:true)
dobMonth (nullable:true)
dobDay (nullable:true)
id (nullable:false)
imgUrl (nullable:true)
siteStandardAddress (nullable:true)
}
def beforeInsert = {
//to do: before insert, capture current email that is stored in the db
}
def afterInsert={
//resave email
}
}