Hibernate version:
2.1.0 Alpha 1
Is there a way to do arbitrary joins in NHibernate?
For example
db tables
[A].ID
[A].BID <- id of b class
[B].ID
POCO:
A.BID
B.ID
Mapping:
Code:
<class name="A" table="A">
<id name="ID" type="int" unsaved-value="0">
<generator class="native" />
</id>
<property name="BID" type="int"/>
</class>
<class name="B" table="B">
<id name="ID" type="int" unsaved-value="0">
<generator class="native" />
</id>
</class>
Now, I want to get a list of all [a] types that match my b.ID in a critiera query.
crit = session.CreateCriteria(typeof(A))
.createCritieria("B", "B")
.Add(Expression.IdEq(4));
The problem is, NHIbernate does not know how to get from object a to object b (there is no mapping).
How can I say something like:
crit = session.CreateCriteria(typeof(A))
.createCritieria("B", "B").On(Expression.Eq(A.ID, B.ID)
.Add(Expression.IdEq(4));
Obviously my domain is more complex than this, the question really is how to join two classes that do not have a mapped association using a critieria query.
Thanks