Subsonic Oracle autoincrement problem
I think this question has been done before, but I don't find a clear answer. I have migrated SQl Server 2005 database to oracle 11. I am using subsonic 2.1. I have manged to create all the data layer classes, and generates everything well. But the problem turns up when I try to make an insert in the database: Oracle does not have autoincrement in the primary key unless you define a sequence and a trigger. In consequence, Subsonic defines all the Insert methods in the controller with the id column. Is there a way to avoid subsonic not generate Insert methods with the id column, which I am 开发者_JAVA技巧going to generate using a trigger and a sequence?
Thanks a lot
SToledo
UPDATE I finally did a horrible hack (I feel ashamed) in Subsonic 2.1 source code. I did modify OracleDataProvider to set id-named columns to be autoincrement to true. Then, the template will behave as I expect. I know is a terrible hack, but it works for me. Thanks for your help guys.
Don't know about Subsonic, but if number of tables is relatively small, you can modify BEFORE-INSERT trigger to disable nullity check:
CREATE OR REPLACE TRIGGER trig_BI
BEFORE INSERT
ON tab_name
FOR EACH ROW
BEGIN
--IF :NEW.key_column IS NULL
--THEN
SELECT tab_seq.NEXTVAL INTO :NEW.key_column FROM DUAL;
--END IF;
END;
精彩评论