Hi,
I have a problem with nhibernate mapping by code.
I have those tables:

<https://lh3.googleusercontent.com/-Nmirb33-cUU/V301WEVRXXI/AAAAAAAA_-o/FM3asmLNQekvJprHftoJnB1KzY-ROg1XACLcB/s1600/dbdiag.png>
















That are mapped to the corresponding entities.

Those entities are mapped On-To-One because:
1. Order can have 1 or 0 Heats. 
2. Heat can have 1 or 0 Order.
3. Combination of OrderId and HeatId must be unique.

Mapping:

public class OrderMap : ClassMapping<Order>
{
    public OrderMap ()
    {       
        Property(o => o.Name);
 
        OneToOne(o => o.HeatOrder,
                 map =>
                 {
                     map.PropertyReference(typeof(Heat).GetProperty("Order"
));
                     map.Cascade(Cascade.All);
                 });
    }
}


public class HeatMap : ClassMapping<Heat>
{
    public HeatMap ()
    {       
        Property(o => o.Name);
 
        OneToOne(o => o.HeatOrder,
                 map =>
                 {
                     map.PropertyReference(typeof(Order).GetProperty("Heat"
));
                     map.Cascade(Cascade.All);
                 });
    }


}


public class HeatOrderMap: ClassMapping<HeatOrder>
{
    public UserDetailMap()
    {
       
        ManyToOne(o => o.Heat,
                  o =>
                  {
                      o.Column("HeatId");
                      o.Unique(true);
                  });

ManyToOne(o => o.Order,
                  o =>
                  {
                      o.Column("OrderId");
                      o.Unique(true);
                  });
    }
} 


The problem I have is the following one:
var result = Session.QueryOver<Order>().Where(x=>x.HeatOrder == 
null).List();

the result creates the following SQL (I deliberately put * cause I don't 
want to write all the columns here):
Select *
>From Order this
Left Outer Join HeatOrder ho on ho.OrderId = this.OrderId
Where this.Id Is Null

the problem is in Where. It tests for this.Id Is Null instead of ho.Id is 
null.

Why?

How can I make this work?
Please help


-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to