I have a class as:
class Facebook {
long id
String username
String email
String first_name
String last_name
Date birthday
String gender
String link
static hasMany = [friends: FacebookFriend]
static constraints = {
id generator:'assigned'
birthday blank:false, nullable:true
gender blank:false, nullable:true
}
}
Based on the documentation for Hibernate and Grails id generator:'assigned'
is all I need to be able to set the id manually. However, every time I run the code the ID gets overwritten by GORM, even though I manually set it before calling the .save(flush:true, failOnError:true)
method. When I output the id from the object before and after save this is what I get:
ID before save is: 12345645
ID after save is: 1
I'm new to Grails but based on all I've read it seems I'm doing what I'm supposed to. Can anyone provide some insight? Thanks!
My next step is to run the app on Grails 2.3.4 just in case.