AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

problem genereating code for NHibernate (legacy database) #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. follow guide on creating NH's class using codesmith
2. Try generating code

What is the expected output? 
NH related class to be generated

What do you see instead?
Error message:
Rendering output 'NHMaster'...
  Generated: C:\Projects\POC\NHibernateLibrary\HbmMaps\LANGUAGE.hbm.xml
  Generated: 
C:\Projects\POC\NHibernateLibrary\BusinessObjects\LANGUAGE.generated.cs
ERROR: C:\Projects\POC\NHibernateLibrary\NH.csp(0,0) ORA-
00904: "IDX"."TABLE_TYPE": invalid identifier

Stack Trace:
   at System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle 
errorHandle, Int32 rc)
   at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle 
statementHandle, CommandBehavior behavior, Boolean needRowid, 
OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals)
   at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle 
statementHandle, CommandBehavior behavior, ArrayList& 
resultParameterOrdinals)
   at System.Data.OracleClient.OracleCommand.ExecuteReader(CommandBehavior 
behavior)
   at SchemaExplorer.OracleSchemaProvider.GetTableIndexes(String 
connectionString, TableSchema table)
   at SchemaExplorer.TableSchema.get_Indexes()
   at NHibernateHelper.TableSearchCriteria.GetIndexSearchCriteria
(Dictionary`2 map)
   at NHibernateHelper.SearchCriteria.GetAllSearchCriteria(TableSchema 
table)
   at _CodeSmith.NHibernateMaster_cst.ManagerObjectTemplate.__RenderMethod1
(TextWriter writer, Control control)
   at CodeSmith.Engine.DelegateControl.Render(TextWriter writer)
   at CodeSmith.Engine.Control.RenderChildren(TextWriter writer)
   at CodeSmith.Engine.Control.Render(TextWriter writer)
   at CodeSmith.Engine.CodeTemplate.Render(TextWriter writer)
   at CodeSmith.Engine.CodeTemplate.RenderToFile(OutputFile outputFile, 
Boolean overwrite)
   at _CodeSmith.NHibernateMaster_cst.RenderManagerObjects(TableSchema 
table)
   at _CodeSmith.NHibernateMaster_cst.Render(TextWriter writer)
   at CodeSmith.Engine.CodeTemplate.RenderToString()
   at CodeSmith.Engine.ProjectCodeGenerator.GenerateCode(CodeSmithProject 
csp)
Unable to render output NHMaster, skipping...
Done rendering outputs: 0 succeeded, 1 failed, 0 skipped (1030ms).

What version of the product are you using?
V5.0

Please provide any additional information below.
The legacy tables:

Table name - LANGUAGE
CREATE TABLE LANGUAGE
(
  LANG              VARCHAR2(10 BYTE)           NOT NULL,
  LANG_DESCRIPTION  VARCHAR2(100 BYTE),
  CREATE_DATE       DATE                        DEFAULT 
SYSDATE               NOT NULL,
  CREATE_USER       VARCHAR2(30 BYTE)           DEFAULT 
USER                  NOT NULL,
  MODIFY_DATE       DATE,
  MODIFY_USER       VARCHAR2(30 BYTE)
)
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;

CREATE UNIQUE INDEX LANGUAGE_PK ON LANGUAGE
(LANG)
LOGGING
NOPARALLEL;

CREATE OR REPLACE TRIGGER tr_rq_language
after insert or update or delete
on language
for each row
declare
    l_record_id            number;
    l_trans_id            number;
    l_dml_type            varchar2(10);
begin
    l_dml_type := iif.x(inserting, 'INSERT', iif.x
(updating, 'UPDATE', 'DELETE'));
    if not cc_rpl_elements.remote_operation and not 
cc_rpl_elements.skip_flag then
        -- Get Transaction ID
        l_trans_id := cc_rpl_elements.get_trans_id;
        -- Get Record ID
        select    queue_record_seq.nextval
        into    l_record_id
        from    dual;
        cc_rpl_elements.create_rpl_trans_dtl (
            'LANGUAGE',
            l_dml_type,
            l_record_id);

        if deleting then
            insert into rq_language (
                 lang,
                trans_id,
                record_id)
            values (
                 :old.lang,
                l_trans_id,
                l_record_id);
        else
            insert into rq_language (
                 trans_id,
                 record_id,
                 lang,
                 lang_description,
                 create_date,
                 create_user,
                 modify_date,
                 modify_user)
            values (
                l_trans_id,
                l_record_id,
                :new.lang,
                :new.lang_description,
                :new.create_date,
                :new.create_user,
                :new.modify_date,
                :new.modify_user);
        end if;
    end if;
end;
/
SHOW ERRORS;

ALTER TRIGGER TR_RQ_LANGUAGE DISABLE;

CREATE OR REPLACE TRIGGER TR_BUR_LANGUAGE
before update
on LANGUAGE
for each row
declare
begin
if not cc_rpl_elements.remote_operation then
-- update the Modify User and Date
begin
:new.modify_user :=user;
:new.modify_date := sysdate;
end;
end if;
end;
/
SHOW ERRORS;

ALTER TABLE LANGUAGE ADD (
  CONSTRAINT LANGUAGE_PK
 PRIMARY KEY
 (LANG));

GRANT DELETE ON  LANGUAGE TO DATA_ADMIN;

GRANT INSERT, SELECT, UPDATE ON  LANGUAGE TO DATA_ENTRY;

GRANT SELECT ON  LANGUAGE TO DATA_REPORT;

GRANT SELECT ON  LANGUAGE TO DATA_VIEW;

GRANT DELETE, INSERT, SELECT, UPDATE ON  LANGUAGE TO WEBAGENT;

table - LANGUAGE_TL
CREATE TABLE LANGUAGE_TL
(
  LANG                 VARCHAR2(10 BYTE)        NOT NULL,
  GUI_LANG             VARCHAR2(10 BYTE)        NOT NULL,
  LANG_DESCRIPTION_TL  VARCHAR2(100 BYTE)       NOT NULL,
  ORDER_LIST           NUMBER(2),
  CREATE_DATE          DATE                     DEFAULT 
SYSDATE               NOT NULL,
  CREATE_USER          VARCHAR2(30 BYTE)        DEFAULT 
USER                  NOT NULL,
  MODIFY_DATE          DATE,
  MODIFY_USER          VARCHAR2(30 BYTE)
)
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;

CREATE UNIQUE INDEX LT1_PK ON LANGUAGE_TL
(LANG, GUI_LANG)
LOGGING
NOPARALLEL;

CREATE OR REPLACE TRIGGER tr_rq_language_tl
after insert or update or delete
on language_tl
for each row
declare
    l_record_id            number;
    l_trans_id            number;
    l_dml_type            varchar2(10);
begin
    l_dml_type := iif.x(inserting, 'INSERT', iif.x
(updating, 'UPDATE', 'DELETE'));
    if not cc_rpl_elements.remote_operation and not 
cc_rpl_elements.skip_flag then
        -- Get Transaction ID
        l_trans_id := cc_rpl_elements.get_trans_id;
        -- Get Record ID
        select    queue_record_seq.nextval
        into    l_record_id
        from    dual;
        cc_rpl_elements.create_rpl_trans_dtl (
            'LANGUAGE_TL',
            l_dml_type,
            l_record_id);

        if deleting then
            insert into rq_language_tl (
                 lang,
                 gui_lang,
                trans_id,
                record_id)
            values (
                 :old.lang,
                 :old.gui_lang,
                l_trans_id,
                l_record_id);
        else
            insert into rq_language_tl (
                 trans_id,
                 record_id,
                 lang,
                 gui_lang,
                 lang_description_tl,
                 order_list,
                 create_date,
                 create_user,
                 modify_date,
                 modify_user)
            values (
                l_trans_id,
                l_record_id,
                :new.lang,
                :new.gui_lang,
                :new.lang_description_tl,
                :new.order_list,
                :new.create_date,
                :new.create_user,
                :new.modify_date,
                :new.modify_user);
        end if;
    end if;
end;
/
SHOW ERRORS;

ALTER TRIGGER TR_RQ_LANGUAGE_TL DISABLE;

CREATE OR REPLACE TRIGGER TR_BUR_LANGUAGETL
before update
on LANGUAGE_TL
for each row
declare
begin
if not cc_rpl_elements.remote_operation then
-- update the Modify User and Date
begin
:new.modify_user :=user;
:new.modify_date := sysdate;
end;
end if;
end;
/
SHOW ERRORS;

ALTER TABLE LANGUAGE_TL ADD (
  CONSTRAINT LT1_PK
 PRIMARY KEY
 (LANG, GUI_LANG));

ALTER TABLE LANGUAGE_TL ADD (
  CONSTRAINT LT1_GUI_LANG_FK 
 FOREIGN KEY (GUI_LANG) 
 REFERENCES LANGUAGE (LANG));

ALTER TABLE LANGUAGE_TL ADD (
  CONSTRAINT LT1_LANG_FK 
 FOREIGN KEY (LANG) 
 REFERENCES LANGUAGE (LANG));

GRANT DELETE ON  LANGUAGE_TL TO DATA_ADMIN;

GRANT INSERT, SELECT, UPDATE ON  LANGUAGE_TL TO DATA_ENTRY;

GRANT SELECT ON  LANGUAGE_TL TO DATA_REPORT;

GRANT SELECT ON  LANGUAGE_TL TO DATA_VIEW;

GRANT DELETE, INSERT, SELECT, UPDATE ON  LANGUAGE_TL TO WEBAGENT;

Original issue reported on code.google.com by herman...@gmail.com on 28 Jan 2009 at 5:23

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 28 Jan 2009 at 10:15

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 2 Feb 2009 at 1:50

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 2 Feb 2009 at 1:50

GoogleCodeExporter commented 9 years ago
I am unable to execute your oracle schema. Could you please make sure it 
executes on
a fresh schema.

Original comment by bniemyjski on 2 Feb 2009 at 1:56

GoogleCodeExporter commented 9 years ago

Original comment by shannon....@gmail.com on 21 Apr 2009 at 3:58

GoogleCodeExporter commented 9 years ago
Hello,

I was able to get that script to execute via sql plus. However, the triggers 
were not
added. I was able to generate against the latest version of CodeSmith and 
NHibernate.
Please let me know if you are still experiencing issues..

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 2 Jul 2009 at 1:09