<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="TProDataTransferObjects" assembly="TProDataTransferObjects" auto-import="true"> <class name="ProjectExts" table="project" lazy="false"> <id name="ProjectID" column="proj_id" type="string"> <generator class="assigned"/> </id>
<property column="manager_emplid" name="ManagerEmpId" ></property> <one-to-one class="NewProjects" name="NewProjectTable" cascade="none"></one-to-one> <one-to-one class="Users" name="UserTable" foreign-key="ManagerEmpId" cascade="none"></one-to-one>
<set name="Activities" lazy="true" cascade="none"> <key column="proj_id" /> <one-to-many class="ProjectActivity"/> </set>
<one-to-one class="ProjectIndicators" name="Indicators" cascade="none"></one-to-one> <one-to-one class="ProjectOthers" name="Others" cascade="none"></one-to-one>
</class> </hibernate-mapping>
this is my query in c#
"from ProjectExts a inner join fetch a.Activities c inner join fetch a.NewProjectTable b left join fetch a.UserTable d where a.ProjectID =:ProjectID and c.LastUpdateDate =(select max(LastUpdateDate) from a.Activities where a.ProjectID =:ProjectID)";
but it resulting in this query
SELECT projectext0_.proj_id AS proj1_8_0_, activities1_.PROJ_ID AS PROJ1_21_1_, newproject2_.PROJ_ID AS PROJ1_6_2_, users3_.user_id AS user1_28_3_, projectext0_.RAIL_ID AS RAIL2_8_0_, projectext0_.US_ROUTE AS US3_8_0_, projectext0_.AOHD_INITIALS AS AOHD4_8_0_, projectext0_.PROG_TYP_ID AS PROG5_8_0_, projectext0_.PRIM_WORK_TYPE_ID AS PRIM6_8_0_, projectext0_.PROFILE_STATUS AS PROFILE7_8_0_, projectext0_.RR_INVOLVEMENT AS RR8_8_0_, projectext0_.OEL_PRIORITY AS OEL9_8_0_, projectext0_.EXPANDED_DESCR AS EXPANDED10_8_0_, projectext0_.BRIDGE_LOCATION AS BRIDGE11_8_0_, projectext0_.BRIDGE_PRIORITY AS BRIDGE12_8_0_, projectext0_.BRIDGE_TEAM_LEADER AS BRIDGE13_8_0_, projectext0_.DEMO_ID AS DEMO14_8_0_, projectext0_.STATE_ROUTE_SYSTEM AS STATE15_8_0_, projectext0_.FINAL_VOUCHER_COMNT AS FINAL16_8_0_, projectext0_.LIGHTING_TYPE_ID AS LIGHTING17_8_0_, projectext0_.IMPROVEMENT_TYPE_ID AS IMPROVE18_8_0_, projectext0_.AD_TYPE_ID AS AD19_8_0_, projectext0_.PPI_ID AS PPI20_8_0_, projectext0_.TMP_STATE_ROUTE AS TMP21_8_0_, projectext0_.OEL_MAP_SURVEY_COMNT AS OEL22_8_0_, projectext0_.CHANGE_REASON AS CHANGE23_8_0_, projectext0_.EDW_TYPE_ID AS EDW24_8_0_, projectext0_.LOC_IMG_TYPE_ID AS LOC25_8_0_, projectext0_.CONSULTANT_ID AS CONSULTANT26_8_0_, projectext0_.manager_emplid AS manager27_8_0_, projectext0_.SPONSOR_ID AS SPONSOR28_8_0_, projectext0_.ENGINEER_EMPLID AS ENGINEER29_8_0_, projectext0_.MPO_TIP_ID AS MPO30_8_0_, projectext0_.REC_STATUS AS REC31_8_0_, projectext0_.ACTUAL_LET_DT AS ACTUAL32_8_0_, projectext0_.RCVD_FIN_PLANS_DT AS RCVD33_8_0_, projectext0_.PROJ_COMPLETE_DT AS PROJ34_8_0_, projectext0_.MGMNT_DIR_LET_DT AS MGMNT35_8_0_, projectext0_.FIELD_INVESTIGATION_DT AS FIELD36_8_0_, projectext0_.LOC_PHOTO_DT AS LOC37_8_0_, projectext0_.LOC_FILM_SCAN_DT AS LOC38_8_0_, projectext0_.LOC_IMAGE_REG_DT AS LOC39_8_0_, projectext0_.LOC_COMPLETE_DT AS LOC40_8_0_, projectext0_.LOC_PHOTO_RCVD_DT AS LOC41_8_0_, projectext0_.LOC_SURVEY_RQST_DT AS LOC42_8_0_, projectext0_.MGMNT_DIR_ROW_DT AS MGMNT43_8_0_, projectext0_.AD_SUBMIT_DT AS AD44_8_0_, projectext0_.INVOICE_SUBMIT_DT AS INVOICE45_8_0_, projectext0_.PROJ_ADVERTISEMENT_DT AS PROJ46_8_0_, projectext0_.ALIGNMENT_START_DT AS ALIGNMENT47_8_0_, projectext0_.ALIGNMENT_FINISH_DT AS ALIGNMENT48_8_0_, projectext0_.PHOTO_CROSS_SECT_START_DT AS PHOTO49_8_0_, projectext0_.PHOTO_CROSS_SECT_FINISH_DT AS PHOTO50_8_0_, projectext0_.MAP_START_DT AS MAP51_8_0_, projectext0_.MAP_FINISH_DT AS MAP52_8_0_, projectext0_.OPEN_TO_TRAFFIC_DT AS OPEN53_8_0_, projectext0_.STIP_CD AS STIP54_8_0_, projectext0_.FED_EXEMPT_CD AS FED55_8_0_, projectext0_.MEASURE_SYS_CD AS MEASURE56_8_0_, projectext0_.LET_RESP_CD AS LET57_8_0_, projectext0_.PRIORITY_CD AS PRIORITY58_8_0_, projectext0_.CORRIDOR_CD AS CORRIDOR59_8_0_, projectext0_.DOT_SPLOST_AMT AS DOT60_8_0_, projectext0_.BID_AWARD_AMT AS BID61_8_0_, projectext0_.INVOICE_AMT AS INVOICE62_8_0_, projectext0_.EXISTING_LANE_CNT AS EXISTING63_8_0_, projectext0_.BRIDGE_SITE_CNT AS BRIDGE64_8_0_, projectext0_.BRIDGE_CNT AS BRIDGE65_8_0_, projectext0_.PROPOSED_LANE_CNT AS PROPOSED66_8_0_, projectext0_.PRE_PARCEL_CNT AS PRE67_8_0_, projectext0_.INTERSECTION_CNT AS INTERSE68_8_0_, projectext0_.HORIZ_ZONE AS HORIZ69_8_0_, projectext0_.HORIZ_DATUM AS HORIZ70_8_0_, projectext0_.VERT_DATUM AS VERT71_8_0_, projectext0_.DBE_ACTUAL_PCT AS DBE72_8_0_, projectext0_.DBE_PCT AS DBE73_8_0_, projectext0_.MODEL_YR AS MODEL74_8_0_, projectext0_.ENVDOC_ENV_DOC_SEQ AS ENVDOC75_8_0_, projectext0_.AD_COST AS AD76_8_0_, projectext0_.ALIGNMENT_PERCENT_COMPLETE AS ALIGNMENT77_8_0_, projectext0_.PHOTO_CROSS_PERCENT_COMPLETE AS PHOTO78_8_0_, projectext0_.MAP_PERCENT_COMPLETE AS MAP79_8_0_, projectext0_.const_stat_cd AS const80_8_0_, projectext0_.LAST_DML_DTTM AS LAST81_8_0_, projectext0_.LAST_DML_USER AS LAST82_8_0_, activities1_.ACTIVITY_ID AS ACTIVITY2_21_1_, activities1_.last_dml_dttm AS last3_21_1_, activities1_.LAST_DML_USER AS LAST4_21_1_, activities1_1_.CONST_STAT_CD AS CONST2_22_1_, activities1_1_.CONCEPT_TEXT AS CONCEPT3_22_1_, activities1_1_.CONST_AUTH_DT AS CONST4_22_1_, activities1_1_.CONST_LATEST_EST_DT AS CONST5_22_1_, activities1_1_.CONST_DIST_ASSIGNED AS CONST6_22_1_, activities1_1_.CON_CONST_EST_PREP_DT AS CON7_22_1_, activities1_1_.CONST_COST_EST_AMT AS CONST8_22_1_, activities1_1_.FINAL_CONST_AMT AS FINAL9_22_1_, activities1_1_.LAST_DML_DTTM AS LAST10_22_1_, activities1_1_.LAST_DML_USER AS LAST11_22_1_, activities1_2_.PE_AUTH_DT AS PE2_23_1_, activities1_2_.PE_DIST_ASSIGNED AS PE3_23_1_, activities1_2_.PE_COST_EST_AMT AS PE4_23_1_, activities1_2_.FINAL_PE_AMT AS FINAL5_23_1_, activities1_2_.PE_COST_EST_DT AS PE6_23_1_, activities1_2_.LAST_DML_DTTM AS LAST7_23_1_, activities1_2_.LAST_DML_USER AS LAST8_23_1_, activities1_3_.PROJ_ID AS PROJ1_24_1_, activities1_3_.COORDINATOR_ID AS COORDINA2_24_1_, activities1_3_.ROW_DIST_ASSIGNED AS ROW3_24_1_, activities1_3_.PLAN_REVIEWER_ID AS PLAN4_24_1_, activities1_3_.PRE_ACQ_MGR_ID AS PRE5_24_1_, activities1_3_.ROW_REVIEWER_ID AS ROW6_24_1_, activities1_3_.ROW_RELOC_SPEC_NAME AS ROW7_24_1_, activities1_3_.ROW_ACQ_MGR_ID AS ROW8_24_1_, activities1_3_.ROW_PLAN_STAT AS ROW9_24_1_, activities1_3_.ROW_FEE_REVIEW_AUDITOR AS ROW10_24_1_, activities1_3_.ACQUIRED_BY_ID AS ACQUIRED11_24_1_, activities1_3_.ROW_AAHO_NAME AS ROW12_24_1_, activities1_3_.ROW_ATTORNEY_COMNT AS ROW13_24_1_, activities1_3_.ROW_ADJUSTMENT AS ROW14_24_1_, activities1_3_.ROW_ADJUSTMENT_PURPOSE AS ROW15_24_1_, activities1_3_.ROW_FUNDING_COMNT AS ROW16_24_1_, activities1_3_.ROW_PRE_CERT_PROJ_COMNT AS ROW17_24_1_, activities1_3_.ROW_ADDL_FUNDING_DETAILS AS ROW18_24_1_, activities1_3_.ROW_PRE_CERT_REVIEW_COMNT AS ROW19_24_1_, activities1_3_.ROW_CONS_PROJ_MGR_ID AS ROW20_24_1_, activities1_3_.ROW_CERT_DT AS ROW21_24_1_, activities1_3_.ROW_CT_EXEC_DT AS ROW22_24_1_, activities1_3_.ROW_ACQ_CT_TO_LOC_DT AS ROW23_24_1_, activities1_3_.ROW_PLAN_APRVL_DT AS ROW24_24_1_, activities1_3_.ROW_AUTH_DT AS ROW25_24_1_, activities1_3_.ROW_COST_EST_DT AS ROW26_24_1_, activities1_3_.ROW_OWNERS_MEETING_DT AS ROW27_24_1_, activities1_3_.ROW_ATTY_COST_EST_RQST_DT AS ROW28_24_1_, activities1_3_.ROW_ATTY_COST_EST_RCVD_DT AS ROW29_24_1_, activities1_3_.ROW_RE_EVAL_RQST_DT AS ROW30_24_1_, activities1_3_.ROW_RE_EVAL_APPROVAL_DT AS ROW31_24_1_, activities1_3_.ROW_CLOSEOUT_NOTIFICATION_DT AS ROW32_24_1_, activities1_3_.ROW_ADJUSTMENT_RQST_DT AS ROW33_24_1_, activities1_3_.ROW_UPDATED_COST_EST_DT AS ROW34_24_1_, activities1_3_.ROW_ADDL_FUNDING_RQST_DT AS ROW35_24_1_, activities1_3_.ROW_PROJ_ASSIGNMENT_DT AS ROW36_24_1_, activities1_3_.ROW_PROJ_ASSIGNED_REVIEWER_DT AS ROW37_24_1_, activities1_3_.ROW_PROJ_INSPECT_REVIEWER_DT AS ROW38_24_1_, activities1_3_.ROW_PROJ_INSPECT_CKLST_COMP_DT AS ROW39_24_1_, activities1_3_.ROW_APPRAISER_BID_MEETING_DT AS ROW40_24_1_, activities1_3_.ROW_APPRAISAL_CONTRACTS_GO_DT AS ROW41_24_1_, activities1_3_.ROW_APPRAISER_NOTICE_PROCED_DT AS ROW42_24_1_, activities1_3_.ROW_REVIEWER_RQST_DT AS ROW43_24_1_, activities1_3_.ROW_GO_ASSIGNMENT_DT AS ROW44_24_1_, activities1_3_.ROW_PLANS_TO_SAAG_DT AS ROW45_24_1_, activities1_3_.MGMNT_DIR_ROW_DT AS MGMNT46_24_1_, activities1_3_.ROW_PLAN_SHEETS_CNT AS ROW47_24_1_, activities1_3_.ROW_COST_EST_AMT AS ROW48_24_1_, activities1_3_.ROW_ATTY_COST_EST_AMT AS ROW49_24_1_, activities1_3_.ROW_STIP_PAGE_NUM AS ROW50_24_1_, activities1_3_.ROW_POST_CERT_COST_EST_AMT AS ROW51_24_1_, activities1_3_.ROW_ADJUSTMENT_AMT AS ROW52_24_1_, activities1_3_.ROW_ALLOTMENT_AMT AS ROW53_24_1_, activities1_3_.ROW_TOTAL_SPENT_AMT AS ROW54_24_1_, activities1_3_.ROW_UPDATED_COST_EST_AMT AS ROW55_24_1_, activities1_3_.ROW_UNEARNED_AMT AS ROW56_24_1_, activities1_3_.ROW_OTHER_AMT AS ROW57_24_1_, activities1_3_.ROW_STIP_AMT AS ROW58_24_1_, activities1_3_.ROW_ADDL_FUNDING_AMT AS ROW59_24_1_, activities1_3_.ROW_PLAN_PARCEL_CNT AS ROW60_24_1_, activities1_3_.FINAL_ROW_AMT AS FINAL61_24_1_, activities1_3_.LAST_DML_DTTM AS LAST62_24_1_, activities1_3_.LAST_DML_USER AS LAST63_24_1_, activities1_4_.UTL_COST_EST_DT AS UTL2_25_1_, activities1_4_.UTL_AUTH_DT AS UTL3_25_1_, activities1_4_.UTL_ACCTNG_CD AS UTL4_25_1_, activities1_4_.UTL_COST_EST_AMT AS UTL5_25_1_, activities1_4_.UTL_DIST_ASSIGNED AS UTL6_25_1_, activities1_4_.UTIL_EST_AMT AS UTIL7_25_1_, activities1_4_.UTIL_RR_CERT_DT AS UTIL8_25_1_, activities1_4_.LOC_UTIL_EST_RQST_DT AS LOC9_25_1_, activities1_4_.LOC_UTIL_EST_RCVD_DT AS LOC10_25_1_, activities1_4_.LAST_DML_DTTM AS LAST11_25_1_, activities1_4_.LAST_DML_USER AS LAST12_25_1_, activities1_.proj_id AS proj1_0__, activities1_.PROJ_ID AS PROJ1_0__, newproject2_.ACTION_REQ_ID AS ACTION2_6_2_, newproject2_.ACTION_TYP_ID AS ACTION3_6_2_, newproject2_.descr AS descr6_2_, newproject2_.REQST_ID AS REQST5_6_2_, newproject2_.LAST_DML_DTTM AS LAST6_6_2_, newproject2_.LAST_DML_USER AS LAST7_6_2_, users3_.ARTEMIS_PWD AS ARTEMIS2_28_3_, users3_.DESCR AS DESCR28_3_, users3_.ORG_ID AS ORG4_28_3_, users3_.USERGRP_USER_GROUP_ID AS USERGRP5_28_3_, users3_.NETWORK_LOGON_ID AS NETWORK6_28_3_, users3_.GDOT_EMPLOYEE_ID AS GDOT7_28_3_, users3_.LAST_DML_DTTM AS LAST8_28_3_, users3_.LAST_DML_USER AS LAST9_28_3_ FROM project_exts projectext0_, PROJECT_ACTIVITY activities1_, PROJECT_CST activities1_1_, PROJECT_PE activities1_2_, PROJECT_ROW activities1_3_, PROJECT_UTL activities1_4_, NEW_PROJECTS newproject2_, TPRO_USERS users3_ WHERE projectext0_.proj_id =activities1_.proj_id AND activities1_.PROJ_ID =activities1_1_.PROJ_ID(+) AND activities1_.PROJ_ID =activities1_2_.PROJ_ID(+) AND activities1_.PROJ_ID =activities1_3_.PROJ_ID(+) AND activities1_.PROJ_ID =activities1_4_.PROJ_ID(+) AND projectext0_.proj_id =newproject2_.PROJ_ID AND projectext0_.proj_id =users3_.user_id(+) -- as you see here the keys are not a match and i am pointing to the foreign key in project..but it keeps pulling projectext0_.proj_id instead of ManagerEmpId
AND projectext0_.proj_id =:p0 AND activities1_.last_dml_dttm= (SELECT MAX(activities4_.last_dml_dttm) FROM PROJECT_ACTIVITY activities4_ WHERE projectext0_.proj_id=activities4_.proj_id AND projectext0_.proj_id =:p1 );
this is the users class <class name="Users" table="users" lazy="false"> <id name="UserId" column="user_id"> <generator class="assigned"/> </id> </class>
any ideas would help... thanks
|