I noticed when using any kind of a projection on a mapping that contains either a component or a reference the component/reference gets cut off in the query.
If there's any restrictions on the component/reference then the query fails.
Example:
public ItemMap()
{
Table("Item");
Id(x => x.KeyColumn);
Map(x => x.SomeData1);
Map(x => x.SomeData2);
References(x => x.SomeReference, "
KeyColumn ")
.Fetch.Join();
}
session.CreateCriteria<Item>()
.Add(Restrictions.Eq("SomeReference.Column2", "value"))
.SetProjection(Projections.Constant("1"))
.List();
Obviously this isn't something real, but it doesn't matter which projection is used, Projections.RowCount() or anything. This will fail because the join gets removed. Is there anything I can do to get around this?