Ok then my bad I guess.

I will try there.

 ---- Being human is the strangest thing I have ever done.


Jerry Porter



----- Original Message ----
From: Fabio Maulo <[EMAIL PROTECTED]>
To: nhibernate-development@googlegroups.com
Sent: Thursday, October 16, 2008 3:58:02 PM
Subject: [nhibernate-development] Re: Newbee trying to get many-to-many 
relationships to work


Hi jep9816.
This is the development-group for NH developers.

For support request the right place is the users group in 
http://groups.google.com/group/nhusers


2008/10/16 jep9816 <[EMAIL PROTECTED]>


Hello,

I am a newbee to nhibernate and I would like to get some help
understanding many-to-many relationship mapping.

I previously came from a Java/WebObjects background and am used to an
ORM based technology and I am trying to move to .NET as rapidly as
possible.

After a bunch of hairpulling I figured out the basic mapping between
my tables in a "readonly" way, however, when I try to save to the
tables I am getting errors.

Kindly take a look and please give any advise.

Thanks,

Jerry

My setup:
VS2005 .Net 2.0
Oracle 10g

Simple table structure is

USERINFO<----->>USER_USERGROUP<<----->USERGROUP
(SysUser class)     (No class generated)            (SysGroup class)
PK oid                   PK oid_user                        PK oid
                            PK oid_user_group

I created the class files and mapping files and am able to fetch
against the database.
But when I try to save just a SysUser I get the following abbreviated
error:
Invalid index 4 for this OracleParameterCollection with Count=4

Mapping files:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="ObjectModel.SysUser, ObjectModel" table="userinfo">
       <id name="oid" column="oid" type="Decimal" length="22">
           <generator class="sequence" />
       </id>
       <property name="disabled" column="disabled" type="String"
length="5"/>
       <property name="eMailAddress" column="email_address"
type="String" length="65"/>
       <property name="firstName" column="first_name" type="String"
length="100"/>
       <property name="lastLoginDate" column="last_login_date"
type="DateTime" length="7"/>
       <property name="lastName" column="last_name" type="String"
length="100"/>
       <property name="loginFailureCount"
column="login_failure_count" type="Decimal" length="10"/>
       <property name="middleName" column="middle_name" type="String"
length="100"/>
       <property name="password" column="password" type="String"
length="65"/>
       <property name="phone" column="phone" type="String"
length="65"/>
       <property name="sessionTimeout" column="session_timeout"
type="Decimal" length="10"/>
       <property name="username" column="username" type="String"
length="65"/>

       <bag name="userGroups" table="user_usergroup" cascade="save-
update" lazy="false" inverse="true">
           <key column ="oid_user" />
           <many-to-many class="ObjectModel.SysUserGroup,
ObjectModel" column="oid_user_group" />
       </bag>
   </class>
</hibernate-mapping>

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="ObjectModel.SysUserGroup, ObjectModel"
table="usergroup">
       <id name="oid" column="oid" type="Decimal" length="22">
           <generator class="sequence" />
       </id>
       <property name="name" column="group_name" type="String"
length="65"/>

       <bag name="userRoles" table="usergroup_userrole"
cascade="none" lazy="false" inverse="true">
           <key column ="oid_user_group" />
           <many-to-many class="ObjectModel.SysUserRole, ObjectModel"
column="oid_user_role" />
       </bag>

       <bag name="users" table="user_usergroup" cascade="save-update"
lazy="false" inverse="true">
           <key column ="oid_user_group" />
           <many-to-many class="ObjectModel.SysUser, ObjectModel"
column="oid_user" />
       </bag>
   </class>
</hibernate-mapping>



-- 
Fabio Maulo



      

Reply via email to