GORM inconsistency between two computers

richard orama

New member
I am developing my first Grails application using MySQL. I have 2 development computers - one at home and another in the office. I am having an issue with deletes.

Among others, I have 2 associated domains:

class Specimen {

...

static hasMany = [patienttbdrug: PatientTBDrug, requestreason: RequestReason, patienttest: PatientTest]
static belongsTo = [patient: Patient, facility: Facility, patientcategory: PatientCategory, receivedby: Staff]

...

}

and

class Facility {

...

static belongsTo = [district: District]
static hasMany = [specimen: Specimen]

static mapping = {
specimen cascade: "save-update"
}

...

}


On the home computer all is perfect because when I try to delete a facility which has specimens, it fails to delete because of the children - note that cascade delete is off. This is good. However, using exactly the same application and data/database on the office computer, when I try to delete a facility which has specimens, the facility gets deleted and leaves the children (specimens) intact (orphaned).

Any general thoughts on what could be causing this - is it some differences in MySQL configuration, etc?

Thanks.
 

dave

Administrator
Staff member
I once had behavioural differences with mysql between machines, it turned out it was because I had been copying tables across manually between computers, and I had caused a a difference in the table format on some tables. Some were InnoDB, others were ISAM, and this was causing foreign keys not to be created correctly. Just a thought.
 

richard orama

New member
Thanks Dave, but this is unlikely to be the cause because I do not copy tables across. My databases are auto-created by Grails.

I once had behavioural differences with mysql between machines, it turned out it was because I had been copying tables across manually between computers, and I had caused a a difference in the table format on some tables. Some were InnoDB, others were ISAM, and this was causing foreign keys not to be created correctly. Just a thought.
 

rorama

New member
It was because the database engine on the home computer is InnoDb, and the office computer is MyISAM. I switched MyISAM to InnoDb and it works perfect!
 

dave

Administrator
Staff member
Same issue I ran into then, When you are likely to be using different dialects between development machines and servers, I've found it now pays to explicitly state the dialect you want to use in the database definition in datasource.groovy, i.e. with dialect="org.hibernate.dialect.MySQL5InnoDBDialect" for InnoDB.
 

rorama

New member
Thanks Dave. I will try dialect="org.hibernate.dialect.MySQL5InnoDBDialect " in the datasource.groovy.
 
Top