I set up the test class and mapping below to try and do the above. The
alternate id property (Confirmation) does not get hydrated, although
the additional SELECT per section 5.5 of the docs is there.

What must I change to get his to work?

Cheers,
Berryl


    public class TicketOrder
    {
        public virtual int Id { get; set; }
        public virtual string Description { get; set; }
        public virtual int Confirmation { get; set; }
    }

  <class name="TicketOrder" >

    <id name="Id">
      <generator class="hilo" />
    </id>

    <property name="Description" />

    <property name="Confirmation" generated="insert" insert="false"
update="false">
      <column name="Confirmation" sql-type="int IDENTITY(1,1)" />
    </property>

  </class>

        [Test]
        public void
Confirmation_OnSave_ConfirmationNbr_is_incremented() {

            using (var tx = _session.BeginTransaction()) {
                _session.Save(_ticket1);
                tx.Commit();
            }
            Assert.That(_ticket1.Id, Is.GreaterThan(0));
            Assert.That(_ticket1.Confirmation, Is.GreaterThan(0));
        }


    create table TicketOrder (
        Id INT not null,
       Description TEXT,
       Confirmation int IDENTITY(1,1),
       primary key (Id)
    )

NHibernate: INSERT INTO TicketOrder (Description, Id) VALUES (@p0,
@p1);@p0 = 'one' [Type: String (0)], @p1 = 32768 [Type: Int32 (0)]
 2011-06-03 12:50:13,042 DEBUG SELECT ticketorde_.Confirmation as
Confirma3_0_ FROM TicketOrder ticketorde_ WHERE ticketorde_.Id=@p0;@p0
= 32768 [Type: Int32 (0)]

NHibernate: SELECT ticketorde_.Confirmation as Confirma3_0_ FROM
TicketOrder ticketorde_ WHERE ticketorde_.Id=@p0;@p0 = 32768 [Type:
Int32 (0)]

Test
'AutoIncrementTests.TicketConfirmationTests.Confirmation_OnSave_TheConfirmationIsAutoIncremented'
failed:
  Expected: greater than 0
  But was:  0

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