Hi everyone, this seems quite a simple problem to solve, still I can't find a solution for it, nor can find on the web some usefull info to head me in the right direction.
So, I'm using MySQL and iBATIS as my ORM tool. I got a table defined like this :
While my insert statement is defined like this in the sql mapping xml generated by iBator.
Please note that this <insert> node has not been generated by iBator, I defined it by hand starting from the default one generated by Ibator and added the <selectKey> element to retrieve the last inserted autoincrement id (this because Ibator generates an insert statement assuming the object has the key field yet assigned, thus ignoring the autoincrement option).
Inserting the first record on DB runs without any error and I can get back the generated autoincrement key (which is, by no surprise, 1!).
During the 2nd execution, anyway, I get this exception :
So, it seems that MySQL is doing something wrong when generating the 2nd key for the next record inserted. Please also note that I suspect this is an iBATIS problem since using autoincrement keys with raw
JDBC code brings no errors at all and everything works fine. I didn't make
test to see if I get this to work WITHOUT retrieving the last inserted key (thus deleting the <selectKey> element in mapping xml), but that would not be what I need the code to do.
Any suggestions to solve this ?
Thank you for your help and support.