these mappings & criteria are identical to another parent/child
relationship that works fine just like this.
the Children collection is never populated.
am I missing something simple?
using (var session =
MyDataContext.Current.SessionManager.OpenSession())
{
using (var trans = session.BeginTransaction())
{
var cust =
session.CreateCriteria<TechSupportCustomer>()
.Add(nhc.Expression.Eq(rValue.NameOf(x =>
x.BillingInstanceID), customerBillingInstanceID))
.SetFetchMode(rValue.NameOf(x =>
x.ANsTNs), FetchMode.Eager)
.UniqueResult<TechSupportCustomer>();
// var cust =
session.Query<TechSupportCustomer>()
// .Where(x => x.BillingInstanceID ==
customerBillingInstanceID)
// .Single();
rValue = cust;
}
}
<xml>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
access="property" auto-import="true" default-cascade="none" default-
lazy="true">
<class xmlns="urn:nhibernate-mapping-2.2" mutable="true"
name="CustomerChild" table="CUSTOMERS_CHILDREN">
<id name="ID" type="System.Int32">
<column name="ID" />
<generator class="sequence">
<param name="sequence">SEQ_CUSTOMER_CHILDREN</param>
</generator>
</id>
<property generated="always" name="CustomerID" insert="false"
update="false" type="System.Int32">
<column name="CUSTOMER_ID" />
</property>
<many-to-one class="Customer" name="Customer">
<column name="CUSTOMER_ID" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
access="property" auto-import="true" default-cascade="none" default-
lazy="true">
<class xmlns="urn:nhibernate-mapping-2.2" mutable="true"
name="Customer" table="CUSTOMERS">
<id name="ID" type="System.Int32">
<column name="ID" />
<generator class="sequence">
<param name="sequence">SEQ_CUSTOMERS</param>
</generator>
</id>
<property name="BillingInstanceID"
type="System.Nullable`1[[System.Decimal]]"><column
name="BILLING_INSTANCE_ID" /></property>
<bag inverse="true" name="Children" mutable="true">
<key>
<column name="ID" />
</key>
<one-to-many class="CustomerChild" />
</bag>
</class>
</hibernate-mapping>
</xml>
I actually use Fluent mappings ..
public CustomerChildMap()
{
base.Table("CUSTOMERS_CHILDREN");
base.Id(x => x.ID, Fields.ID)
.GeneratedBy.Sequence("SEQ_CUSTOMER_CHILDREN")
;
base.References(x => x.Customer)
.Column(Fields.CUSTOMER_ID)
.Not.Nullable()
;
}
public CustomerMap()
{
base.Table("CUSTOMERS");
base.Id(x => x.ID, Fields.ID)
.GeneratedBy.Sequence("SEQ_CUSTOMERS");
base.HasMany<CustomerChild>(x => x.Children)
.KeyColumn(CustomerChildMap.Fields.ID)
.Inverse()
;
}
--
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.