Jeff-Lewis / codesmith

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

NHibernate + Oracle + Codesmith - Many to Many doesnt work #93

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Good day, 

I have problem with generating NHibernate Many to Many ralation ship with 
Oracle 9i. I have CodeSmith Professional 5.0.5 Revision 6362. I downloaded 
templates today (04/16/2009) from 
http://codesmith.googlecode.com/svn/trunk/Templates/Frameworks/NHibernate

I created M:N realtion with three tables 

Payment(PK Id integer,attr) <- Payment_Person(Payment_ID, Person_ID) -> 
Person(PK Id integer, attribute)

But result is generated without many to many:

Person.hbm.xml

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
namespace="ConsoleApplication2.Generated.BusinessObjects" 
assembly="ConsoleApplication2">
    <class name="ConsoleApplication2.Generated.BusinessObjects.PERSON, 
ConsoleApplication2" table="MICHAL_KURITKA.PERSON" lazy="true">
        <id name="Id" column="ID">
            <generator class="assigned" />
        </id>
        <property name="FIRSTNAME" column="FIRSTNAME" />
        <property name="LASTNAME" column="LASTNAME" />
        <property name="AGE" column="AGE" />
    </class>
</hibernate-mapping>

Payment.hbm.xml

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
namespace="ConsoleApplication2.Generated.BusinessObjects" 
assembly="ConsoleApplication2">
    <class 
name="ConsoleApplication2.Generated.BusinessObjects.PAYMENT, 
ConsoleApplication2" table="MICHAL_KURITKA.PAYMENT" lazy="true">
        <id name="Id" column="ID">
            <generator class="assigned" />
        </id>
        <property name="IBAN" column="IBAN" />
        <many-to-one name="BANK" column="BANKID" class="BANK" />
    </class>
</hibernate-mapping>

Original issue reported on code.google.com by kuri...@gmail.com on 16 Apr 2009 at 2:46

GoogleCodeExporter commented 9 years ago

Original comment by tdupont...@gmail.com on 21 Apr 2009 at 3:41

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
Can you please provide us a copy of your schema?

Original comment by tdupont...@gmail.com on 21 Apr 2009 at 4:38

GoogleCodeExporter commented 9 years ago
I have the same issue. I have 2 tables created with a 1-to-many relationship in 
oracle and I did not see the 1-to-many relationship reflected in the results. 
However, in SQL-Server it worked correctly and the 1-to-many relationship was 
reflected in the results. I have attached the schema.

Original comment by olusola....@logion.co.uk on 24 Jun 2009 at 7:15

Attachments:

GoogleCodeExporter commented 9 years ago
CREATE TABLE audix_remote.audix_audit_table 
    (audix_audit_table_id       INTEGER         NOT NULL ENABLE,
    schema_name                 VARCHAR2(30)    NOT NULL 
ENABLE,
    audit_table_name            VARCHAR2(30)    NOT NULL ENABLE,
    audit_insert                NUMBER(1)       NOT NULL 
ENABLE,
    audit_update                NUMBER(1)       NOT NULL 
ENABLE,
    audit_delete                NUMBER(1)       NOT NULL 
ENABLE,
    created_by                  VARCHAR2(255)   NOT NULL 
ENABLE, 
    created_time                TIMESTAMP (4)   WITH TIME ZONE NOT 
NULL ENABLE, 
    amended_by                  VARCHAR2(255), 
    amended_time                TIMESTAMP (4) WITH TIME ZONE 
    );

CREATE TABLE audix_remote.audix_audit_column
    (audix_audit_column_id      INTEGER         NOT NULL ENABLE,
    audix_audit_table_id        INTEGER         NOT NULL ENABLE,
    column_name                 VARCHAR2(30)    NOT NULL 
ENABLE,
    data_type                   VARCHAR2(30)    NOT NULL 
ENABLE,
    audit_column                NUMBER(1)       NOT NULL 
ENABLE,
    created_by                  VARCHAR2(255)   NOT NULL 
ENABLE, 
    created_time                TIMESTAMP (4)   WITH TIME ZONE NOT 
NULL ENABLE, 
    amended_by                  VARCHAR2(255), 
    amended_time                TIMESTAMP (4)   WITH TIME ZONE 
    );

ALTER TABLE audix_remote.audix_audit_table
ADD CONSTRAINT audix_audit_table_pk
PRIMARY KEY (audix_audit_table_id)
USING INDEX
TABLESPACE users;

ALTER TABLE audix_remote.audix_audit_column
ADD CONSTRAINT audix_audit_column_pk
PRIMARY KEY (audix_audit_column_id)
USING INDEX
TABLESPACE users;

ALTER TABLE audix_remote.audix_audit_column
ADD CONSTRAINT column_fk1 
FOREIGN KEY ( audix_audit_table_id ) 
REFERENCES audix_remote.audix_audit_table ( audix_audit_table_id );

Original comment by olusola....@logion.co.uk on 25 Jun 2009 at 11:49

GoogleCodeExporter commented 9 years ago
Hello,

I am unable to reproduce this issue. I applied your schema to the latest 
version of
Oracle and ran against the latest version of NHibernate and it had the same 
exact
output as running against SQL Server. Please update this case if this is not 
what you
are experiencing after upgrading.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 1 Jul 2009 at 5:42

GoogleCodeExporter commented 9 years ago
I obtained latest version of CodeSmith (5.1). The accompanying Nhibernate and 
netTiers templates worked correctly. All 1-many and many-many relationships 
were 
recognised by both templates and the generated code in both cases correctly 
reflected the relationships.

Thanks a lot.

Olusola

Original comment by olusola....@logion.co.uk on 7 Jul 2009 at 10:35

GoogleCodeExporter commented 9 years ago
Hello,

Thanks for the update.

Thanks
-Blake Niemyjski

Original comment by bniemyjski on 7 Jul 2009 at 10:38