I was trying to get Informix serial field to work, so I took your class (org.jboss.ejb.plugins.cmp.jdbc.mysql.JDBCMySQLCreateCommand) and modified it a bit to get the serial (sequence/auto-generated) number out of it after the insert is done.
if you are interested in seeing how it's done in Informix
here is the code.
the code is pretty much the same except for the code where you retrieve the sequece number for MySQL:
// cast to the wrapped statement
org.jboss.ejb.plugins.cmp.jdbc.WrappedStatement ws =
(org.jboss.ejb.plugins.cmp.jdbc.WrappedStatement) ps;
// fetch underlying statement and cast it to Informix native
com.informix.jdbc.IfxStatement ifxStmt =
(com.informix.jdbc.IfxStatement) ws.getUnderlyingStatement();
int serialValue = ifxStmt.getSerial ();
Object pk = null;
if (serialValue != 0) {
pk = new Integer (serialValue);
}
if( pk == null ) {
throw new Exception( "Primary key isn't generated." );
}
log.debug ("Generated serial PK value is: " + pk);
if you need to see it in full just send me e-mail and I will reply with the file.
Alex.
Is all this stuff supported by XDoclet?
Many thanks!
Simone
Do you have one for Sybase Identity columns?
Many thanks!
Simone