I have three table as follows as part of a legacy database whose
schema I cannot change:

USER
(
    ID                    NUMBER(22, 0)      NOT NULL,
    FIRSTNAME    VARCHAR2(50)        NOT NULL,
    LASTNAME     VARCHAR2(50)        NOT NULL
)

ROLE
(
    ID                    NUMBER(22, 0)      NOT NULL,
    NAME             VARCHAR2(50)       NOT NULL
)

USER_ROLE
(
    USER_ID         NUMBER(22, 0)      NOT NULL,
    ROLE_ID         NUMBER(22, 0)      NOT NULL
)

Consequently I have the following mappings with NHibernate 3.0 beta 1:

<class name="User" table="`USER`">
    ...
    <bag name="Roles" lazy="true">
        <key column="`USER_ID`" />
        <one-to-many class="UserRole" not-found="ignore" />
    </bag>
</class>

<class name="Role" table="`ROLE`">
    ...
    <bag name="Users" lazy="true">
        <key column="`ROLE_ID`" />
        <one-to-many class="UserRole" not-found="ignore" />
    </bag>
</class>

<class name="UserRole" table="`USER_ROLE`">
    <composite-id>
        <key-many-to-one name="User" class="User" not-found="ignore" /
>
        <key-many-to-one name="Role" class="Role" not-found="ignore" /
>
    </composite-id>
</class>

I have used not-found because there are plenty of rows in association
tables with IDs that are non-existent in parent tables.

However, when I try to load User.Roles or Role.Users, I still get an
exception such as "No row with the given identifier exists[Role#21]".

Why is not-found not working?

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to