Hello.
Based on this:
http://fabiomaulo.blogspot.com/2010/03/conform-mapping-one-to-one.html
I have two entites:
Plan
{
public virtual int Id { get; set; }
public virtual Payer Payer { get; set; }
}
Payer
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
}
Mapping for it:
orm.Cascade<Payer, Plan >(CascadeOn.Persist | CascadeOn.Merge);
orm.Cascade<Plan, Payer>(CascadeOn.None);
Fetch:
mapper.Customize<CarePlan>(cm => cm.ManyToOne(o => o.Payer, x =>
x.Fetch(FetchKind.Join)));
Simple get:
var plan = session.Query<Plan>().Where(c=>c.Id ==
1).SingleOrDefault();
Console.WriteLine(
plan.Payer.Name);
And I got this query:
select careplan0_.Id
careplan0_.PayerId
from CarePlans careplan0_
where careplan0_.Id = 1 /* @p0 */
and other query
SELECT payer0_.Id ,
payer0_.Name as Name
FROM Payers payer0_
WHERE payer0_.Id = 2
Why I got 2 queries?