I'm having a problem using the schema export util in nhib 3.2 GA where
it adds a column twice in the table create ddl.

I will try and describe the scenario, please let me know if more info
is needed. (see below for layout info)
So first off I am trying to set up a temp database instance so we can
test query logic. I have that going pretty well, it creates a new test
schema when the nhibernate session is started.
I have found:
If I remove the bag from FacilityRoute, I don't get the duplicate
column, but then I don't get the collection either.
If I change the composite-id key-property to key-many-to-one then it
attempts to insert a null into
TBL_FACILITY_ROUTE_LOCATIONS.N_FACILITY_ROUTE_ID even though the
classes have a value.
I am really out of my league when tracing through the nhibernate
source, so I would appreciate any incite anyone can provide.
I can change the table layout if needed, I have read that composite-
ids are bad, but I'm not sure of the best table config to make it
nhibernate friendly.

=============
layout info
=============
:Here is the problem table mapping
<class name="FacilityRouteLocation"
table="TBL_FACILITY_ROUTE_LOCATIONS" lazy="true">
       <composite-id>
         <key-property column="N_TRACKING_LOCATION_ID " type="long"
name="TrackingLocationId" />
         <key-property column="N_FACILITY_ROUTE_ID " type="long"
name="FacilityRouteId" />
       </composite-id>

       <property name="PositionInRoute" column="N_POSITION_IN_ROUTE"
type="int" not-null="true"  />
</class>

:And here is the table that is cause the extra column to be inserted
<class name="FacilityRoute" table="TBL_FACILITY_ROUTE" lazy="true">
       <id name="Id" column="N_FACILITY_ROUTE_ID " type="long" unsaved-
value="-1">
           <generator class="native">
               <param name="sequence">SEQ_FACILITY_ROUTE</param>
          </generator>
      </id>

      <property name="TrackingFacilityId"
column="N_TRACKING_FACILITY_ID" type="long" not-null="true"  />
      <property name="Name" column="C_NAME" type="string" not-
null="true"  />
      <property name="Description" column="C_DESCRIPTION"
type="string" not-null="false"  />
      <property name="IsDeleted" column="N_DELETED" type="bool" not-
null="true"  />

      <bag name="FacilityRouteLocations"
table="TBL_FACILITY_ROUTE_LOCATIONS" cascade="all-delete-orphan"
lazy="false" inverse="false">
        <key column ="N_FACILITY_ROUTE_ID"  />
        <one-to-many class="FacilityRouteLocation"  />
      </bag>
    </class>


:Here is the offending create ddl
    create table U295.TBL_FACILITY_ROUTE_LOCATIONS (
        N_TRACKING_LOCATION_ID  NUMBER(20,0) not null,
       N_FACILITY_ROUTE_ID  NUMBER(20,0) not null,
       N_POSITION_IN_ROUTE NUMBER(10,0) not null,
       N_FACILITY_ROUTE_ID NUMBER(20,0),             <----------------
problem column
       primary key (N_TRACKING_LOCATION_ID , N_FACILITY_ROUTE_ID )
    )


:schema export code
var se = new SchemaExport(_configuration);
se.Execute(true, true, false);






-- 
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