I can't really confirm it, but the scenario you described sounds like the 
expected behavior to me.  So you are right that users should be careful, and 
should not use it in a production environment.  But I will say that using it is 
a good tip for getting around the populating the database for tests problem.  
The other way is to move stuff around within sample-data.xml so the foreign key 
constraints are not violated.  

Nathan


----- "syg6" <[EMAIL PROTECTED]> wrote:
> This is a parameter you can add to your pom.xml under the <jdbc.url>
> section
> for MySQL. It allows DBUnit to populate the database using
> sample-data.xml
> without worrying about the order in which the tables and their data
> appear
> in that file.
> 
> It looks like this:
> 
> <jdbc.url>
> <![CDATA[jdbc:mysql://localhost/myapp?createDatabaseIfNotExist=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;sessionVariables=FOREIGN_KEY_CHECKS=0]]>
> </jdbc.url>
> 
> But I found out the hard way that this should be turned off once your
> app is
> in production. (Perhaps this is something everyone already knew? I
> sure
> didn't ...) Because if you leave it there, even though constraints are
> in
> place and turned on in the database, from your app you will be able
> to
> delete data that you otherwise would not be allowed to because of
> those
> constraints. 
> 
> For example, if you have a COUNTRY table and a PROVINCE table, in
> which your
> PROVINCE table has a foreign key, idCountry, with
> 'sessionVariables=FOREIGN_KEY_CHECKS=0', you can delete a COUNTRY that
> has
> an idCountry in the PROVINCE table, the app doesn't complain. If you
> then
> try to load that PROVINCE you get a 'row doesn't exist' error. Of
> course,
> because the COUNTRY associated with that PROVINCE has been nuked ...
> 
> Anyway, that's my experience. I took the param out, re-started the app
> and I
> could no longer do such dangerous deletes.
> 
> Can anyone confirm this?
> 
> Bob
> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Be-careful-with-sessionVariables%3DFOREIGN_KEY_CHECKS%3D0--tp15037031s2369p15037031.html
> Sent from the AppFuse - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to