Hello!

I was wondering a little bit on the behavior of the hilo-generator.

Mappings:
<class entity-name="Elev" >
    <id name="ID" column="Id" type="Int32" >
      <generator  class="hilo" />
    </id>
    <idbag name="Klasses" table="Elev_Klass" cascade="save-update">
      <collection-id column="collection_index" type="Int32">
        <generator  class="hilo" />
      </collection-id>
      <key column="elev_id" />
      <many-to-many class="Klass" column="klass_id" />
    </idbag>
  </class>

  <class entity-name="Klass"  >
    <id name="ID" column="Id" type="Int32" >
      <generator  class="hilo" />
    </id>
    <idbag name="Elevs" table="Elev_Klass" cascade="save-update">
      <collection-id column="collection_index" type="Int32">
        <generator  class="hilo" />
      </collection-id>
      <key column="klass_id" />
      <many-to-many class="Elev" column="elev_id" />
    </idbag>
  </class>

  <class table="Elev_Klass" entity-name="ElevKlass"  >
    <id name="ID" column="collection_index" type="Int32" >
      <generator  class="hilo" />
    </id>
    <property name="ElevId" column="elev_id" type="Int32" not-
null="true" unique-key="IX_Elev_Klass"/>
    <property name="KlassId" column="klass_id" type="Int32" not-
null="true" unique-key="IX_Elev_Klass"/>
  </class>

Code:
  BurrowFramework framework = new BurrowFramework();

            BeginLog();

            ISessionFactory factory = framework.GetSessionFactory
("Test");

            var configuration = framework.BurrowEnvironment.GetNHConfig
("Test");
            SchemaExport export = new SchemaExport(configuration);
            export.Create(false, true);
            CommitAndStartnNewPersistentContext();

            using (var session = factory.OpenSession())
            {
                Hashtable elev = new Hashtable();
                session.Save("Elev", elev);
                Hashtable klass =  new Hashtable() {};
                List<IDictionary> klasses = new List<IDictionary>
{klass};
                elev["Klasses"] = klasses;

                Hashtable elev2 = new Hashtable();
                Hashtable klass2 = new Hashtable();

                session.Save("Elev",elev2);
                session.Save("Klass",klass2);

                Hashtable elevKlass = new Hashtable();
                elevKlass["ElevId"] = elev2["ID"];
                elevKlass["KlassId"] = klass2["ID"];
                session.Save("ElevKlass", elevKlass);

                Hashtable elev3 = new Hashtable();
                session.Save("Elev", elev);
                Hashtable klass3 = new Hashtable() { };
                List<IDictionary> klasses2 = new List<IDictionary>
{ klass, klass2, klass3 };
                elev["Klasses"] = klasses2;

                session.Save("Elev", elev3);

                session.Flush();
                session.Close();
            }

Using EntityMode.Map. So I understand that the ElevKlass-mapping could
be unnecessary, but it is used for a heavy import job and with the
IStatelessSession interface.

When I save entity with entitName "ElevKlass" causes the
sessionfactory to update the next_hi.
 I expected it to make use of the already reserved id-range of the
idbag "Klasses", but it reservs its own range.

The same behaviour occur when saving Elev from Klass using idbag
"Elevs". So dependning on path taken to save Elev, Klass or ElevKlass
it will create 3 diffrent ranges.

Why is this?
This works perfectly but I have to ask :)

Thanks for answer in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to