In a (late) response to KPixel, I am still facing this problem, and I have simplified the scenario (somewhat), and I present more info here:
A very simple call to ISession.Get(typeof(Evaluation), 69315) causes 7 tables to be queried instead of just the one table whose entity I am requesting. All relationships and entities have lazy="true", so I don't know why these entities are loading. I captured a log4net file for just the specific query, and it's 252KB, so I'll send it to you if you ask for it.
Meanwhile, here are relevant snippets of the mapping files that include relationships that are being retrieved. It may seem overwhelming, but I hope it provides you with whatever little info you need from them to help me determine what's wrong. Thanks in advance.
class Evaluation:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-cascade="all-delete-orphan">
<class name="Byu.Fhss.Sfl.RelateInstitute.Logic.Surveys.Evaluation, RelateInstituteLogic" table="evaluation" lazy="true">
<cache usage="read-write"/>
<id name="Id" column="evaluationId" unsaved-value="0">
<generator class="native"/>
</id>
<many-to-one name="Questionnaire" column="questionnaireId" class="Byu.Fhss.Sfl.RelateInstitute.Logic.Surveys.Questionnaire, RelateInstituteLogic" cascade="none" />
<one-to-one name="FollowUpEvent" property-ref="EventEvaluation"/>
<many-to-one name="Participant" column="participantId"/>
<many-to-one name="Partner" column="partnerId" access="field.camelcase" class="Byu.Fhss.Sfl.RelateInstitute.Logic.Accounts.Participant, RelateInstituteLogic"/>
<many-to-one name="PartnerEvaluation" column="partnerEvaluationId" access="field.camelcase" class="Byu.Fhss.Sfl.RelateInstitute.Logic.Surveys.Evaluation, RelateInstituteLogic"/>
<many-to-one name="OrderDetail" column="orderDetailId"/>
<map name="ResponsesSet" table="response" lazy="true">
<cache usage="read-write"/>
<key>
<column name="evaluationId" unique-key="response_idx"/>
</key>
<!-- this relationship was not queried, so I don't include detail here -->
</map>
<set name="FollowUpsSet" inverse="true" lazy="true">
<cache usage="read-write"/>
<key column="evaluationId"/>
<one-to-many class="Emar.FollowUp.EvaluationTracker, Emar3"/>
</set>
</class>
</hibernate-mapping>
class EventTracker
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-cascade="all-delete-orphan">
<class name="Emar.FollowUp.EventTracker, Emar3" table="eventtracker" lazy="true">
<cache usage="read-write"/>
<id name="Id" column="eventTrackerId" unsaved-value="0">
<generator class="native"/>
</id>
<many-to-one name="EvaluationTracker" column="evaluationTrackerId"/>
<many-to-one name="EventEvaluation" column="eventEvaluationId" class="Byu.Fhss.Sfl.RelateInstitute.Logic.Surveys.Evaluation, RelateInstituteLogic"/>
<many-to-one name="StudyEvent" column="studyEventId"/>
<set name="IncentivesSet" lazy="true" inverse="true">
<cache usage="read-write"/>
<key column="eventTrackerId"/>
<one-to-many class="Emar.FollowUp.Incentive, Emar3"/>
</set>
</class>
</hibernate-mapping>
class OrderDetail:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-cascade="all-delete-orphan">
<class name="Byu.Fhss.Sfl.RelateInstitute.Logic.Purchasing.OrderDetail, RelateInstituteLogic" table="orderdetail" lazy="true">
<cache usage="read-write"/>
<id name="Id" column="orderDetailId" unsaved-value="0">
<generator class="native"/>
</id>
<set name="EvaluationsSet" lazy="true" inverse="true">
<cache usage="read-write"/>
<key column="orderDetailId"/>
<one-to-many class="Byu.Fhss.Sfl.RelateInstitute.Logic.Surveys.Evaluation, RelateInstituteLogic" />
</set>
<set name="TokensSet" lazy="true" inverse="true">
<cache usage="read-write"/>
<key column="orderDetailId"/>
<one-to-many class="Byu.Fhss.Sfl.RelateInstitute.Logic.Purchasing.Token, RelateInstituteLogic" />
</set>
<many-to-one name="Order" column="orderId" not-null="true" class="Byu.Fhss.Sfl.RelateInstitute.Logic.Purchasing.Order, RelateInstituteLogic"/>
<many-to-one name="Product" access="field.camelcase" column="productId" not-null="true" class="Byu.Fhss.Sfl.Purchasing.Product, Purchasing"/>
</class>
</hibernate-mapping>
class Order
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-cascade="all-delete-orphan">
<class name="Byu.Fhss.Sfl.RelateInstitute.Logic.Purchasing.Order, RelateInstituteLogic" table="`order`" lazy="true">
<cache usage="read-write"/>
<id name="Id" column="orderId" unsaved-value="0">
<generator class="native"/>
</id>
<many-to-one name="Customer" column="userId" class="Byu.Fhss.Sfl.RelateInstitute.Logic.Accounts.User, RelateInstituteLogic"/>
<set name="PaymentsSet" inverse="true" order-by="ChargedOn">
<cache usage="read-write"/>
<key column="orderId"/>
<one-to-many class="Byu.Fhss.Sfl.Purchasing.IPayment, Purchasing"/>
</set>
<set name="DetailsSet" inverse="true">
<cache usage="read-write"/>
<key column="orderId"/>
<one-to-many class="Byu.Fhss.Sfl.RelateInstitute.Logic.Purchasing.OrderDetail, RelateInstituteLogic"/>
</set>
</class>
</hibernate-mapping>
class User
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-cascade="all-delete-orphan">
<class name="Byu.Fhss.Sfl.RelateInstitute.Logic.Accounts.User, RelateInstituteLogic" table="`user`" lazy="true" discriminator-value="user" >
<cache usage="read-write"/>
<id name="Id" column="userId" unsaved-value="0">
<generator class="native"/>
</id>
<discriminator column="userType" type="string" length="20"/>
<set name="OrdersSet" lazy="true" inverse="true" order-by="Date">
<cache usage="read-write"/>
<key column="userId"/>
<one-to-many class="Byu.Fhss.Sfl.RelateInstitute.Logic.Purchasing.Order, RelateInstituteLogic"/>
</set>
<subclass name="Byu.Fhss.Sfl.RelateInstitute.Logic.Accounts.Participant, RelateInstituteLogic" discriminator-value="participant" lazy="true">
<set name="EvaluationsSet" lazy="true" inverse="true" order-by="StartDate DESC">
<key column="participantId"/>
<one-to-many class="Byu.Fhss.Sfl.RelateInstitute.Logic.Surveys.Evaluation, RelateInstituteLogic"/>
</set>
</subclass>
</class>
</hibernate-mapping>
class Payment
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-cascade="all-delete-orphan">
<class name="Byu.Fhss.Sfl.Purchasing.IPayment, Purchasing" table="payment">
<cache usage="read-write"/>
<id name="Id" column="paymentId" unsaved-value="0">
<generator class="native"/>
</id>
<discriminator column="paymentType" type="string" length="10"/>
<many-to-one name="Order" column="orderId" class="Byu.Fhss.Sfl.RelateInstitute.Logic.Purchasing.Order, RelateInstituteLogic"/>
<subclass name="Byu.Fhss.Sfl.Purchasing.CreditCardPayment, Purchasing" discriminator-value="credit">
</subclass>
<subclass name="Byu.Fhss.Sfl.RelateInstitute.Logic.Purchasing.TokenPayment, RelateInstituteLogic" discriminator-value="token">
<many-to-one name="Token" column="tokenId" class="Byu.Fhss.Sfl.RelateInstitute.Logic.Purchasing.Token, RelateInstituteLogic"/>
</subclass>
</class>
</hibernate-mapping>