On Wed, Mar 18, 2009 at 9:47 PM, Kengkaj Sathianpantarit <kengka...@gmail.com> wrote: > Interesting, thanks. > > However, I think it's a bit ugly. And what about if we want to insert null > value? >
You can't: `status` VARCHAR(20) NOT NULL DEFAULT 'ready', But I do agree, it is kind of ugly. ;-) I wonder if it would be easier to do this: - use a stored procedure to handle the default value - use the table definition to handle the NOT NULL constraint So you call the stored procedure from ibatis to do the insert, and the procedure checks for the null value and replaces it. That would keep the app code clean, the table definition would keep the data valid, and the stored procedure would manage the default value. Also, if you do this outside of the Java code, be sure to re-read the inserted object in case the database changes it. :) Larry