GORM id column problem

o.hunewald

New member
IHello,

I have a strange problem with GORM when I wan't to save an object:

I have a domain class Project which contains many Samples. The point is I do some batch uploading via Excel-Sheet to my database. Each Sample-object belongs to one Project which needs to exists already in the database. So I load the project from the database and assign it to the sample:

if ("${cell(0)}") {

animalSample.project = Project.findByName("${cell(0)}")?: {
// here comes some error handling if the project doesn't exists
}
}
In the debugger I check and everything looks ok but when I want to save the sample-obj:

sample.save(flush:true)

I get the following error msg:

Class:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException
Message:
Column 'project_id' cannot be null

but there is no column 'project_id'. Only the column 'id', automatically generated. Like I said, with the debugger erverything looks ok. The project has its correct id, but there is no attribute project_id...

Am I doing something wrong here?

Any help would be highly appreciated


Oliver
 
Top