TripSent 和 ReturnCode
我想在这些表中进行左连接,例如
“在 TripSent.ReturnCode = ReturnCode.Id 上左加入 TripSent”
这是我的 TripSent 映射类
public TripSentMap()
{
ImportType<RemittanceDetailTransHeader>();
Schema(Dao.DataAccess.Schema);
Table("EI_TRIP_SENT");
LazyLoad();
Id(x => x.Id)
.Column("ID")
.CustomType("Int64")
.Access.Property()
.CustomSqlType("NUMBER")
.Not.Nullable()
.Precision(12)
.GeneratedBy.Sequence("EI_TRIP_SENT_ID_SEQ");
//EDIT : Removed redundant Mapping Info
References(x => x.ReturnCode)
.Class<ReturnCode>()
.Access.Property()
.Cascade.None()
.LazyLoad()
.Columns("EI_RETURN_CODE_ID");
}
这是我的 HQL
String hql = @"SELECT ts.PartialTripNumber, ts.Sequence, ts.TagIssuer, ts.TagNumber, ts.DateTime, ts.PlazaNumber, ts.LaneNumber, ts.RealCategory, ts.DetectedCategory,
ts.TabulatedCategory, ts.Amount, ts.PassMode, ts.LicensePlate, ts.ImageReason, ts.ReturnCode, ts.TripSentStatus
FROM TripSent ts
WHERE ts.Remittance.Id = :remId";
var transactionDetailsHql = _session.CreateQuery(hql)
.SetParameter("remId", remId)
.List();
这会生成这样的查询
select tripsent0_.PARTIAL_TRIP_NUMBER as col_0_0_,
tripsent0_.SEQUENCE as col_1_0_,
tripsent0_.EI_TAG_ISSUER_ID as col_2_0_,
tripsent0_.TAG_NUMBER as col_3_0_,
tripsent0_.DATE_TIME as col_4_0_,
tripsent0_.PLAZA_NUMBER as col_5_0_,
tripsent0_.LANE_NUMBER as col_6_0_,
tripsent0_.REAL_CATEGORY as col_7_0_,
tripsent0_.DETECTED_CATEGORY as col_8_0_,
tripsent0_.TABULATED_CATEGORY as col_9_0_,
tripsent0_.AMOUNT as col_10_0_,
tripsent0_.EI_PASS_MODE_ID as col_11_0_,
tripsent0_.LICENSE_PLATE as col_12_0_,
tripsent0_.EI_IMAGE_REASON_ID as col_13_0_,
tripsent0_.EI_RETURN_CODE_ID as col_14_0_,
tripsent0_.EI_TRIP_SENT_STATUS_ID as col_15_0_,
tagissuer1_.ID as ID36_0_,
passmode2_.ID as ID14_1_,
imagereaso3_.ID as ID12_2_,
returncode4_.ID as ID28_3_,
tripsentst5_.ID as ID48_4_,
tagissuer1_.DESCRIPTION as DESCRIPT2_36_0_,
tagissuer1_.EI_TAG_CHECK_TYPE_ID as EI3_36_0_,
tagissuer1_.EI_TAG_OSA_ID as EI4_36_0_,
passmode2_.DESCRIPTION as DESCRIPT2_14_1_,
imagereaso3_.DESCRIPTION as DESCRIPT2_12_2_,
returncode4_.DESCRIPTION as DESCRIPT2_28_3_,
tripsentst5_.DESCRIPTION as DESCRIPT2_48_4_
from CENTRO.EI_TRIP_SENT tripsent0_
inner join CENTRO.EI_TAG_ISSUER tagissuer1_
on tripsent0_.EI_TAG_ISSUER_ID = tagissuer1_.ID
inner join CENTRO.EI_PASS_MODE passmode2_
on tripsent0_.EI_PASS_MODE_ID = passmode2_.ID
inner join CENTRO.EI_IMAGE_REASON imagereaso3_
on tripsent0_.EI_IMAGE_REASON_ID = imagereaso3_.ID
inner join CENTRO.EI_RETURN_CODE returncode4_
on tripsent0_.EI_RETURN_CODE_ID = returncode4_.ID
inner join CENTRO.EI_TRIP_SENT_STATUS tripsentst5_
on tripsent0_.EI_TRIP_SENT_STATUS_ID = tripsentst5_.ID
where tripsent0_.EI_REMITTANCE_ID = 12 /* :p0 */
但我想要一个 LEFT OUTER JOIN 而不是
inner join CENTRO.EI_RETURN_CODE returncode4_ on tripsent0_.EI_RETURN_CODE_ID = returncode4_.ID
我找不到如何做到这一点我也尝试过映射
References(x => x.ReturnCode)
.Class<ReturnCode>()
.Access.Property()
.Cascade.None()
.NotFound.Ignore().Nullabe()
.Not.LazyLoad()
.Columns("EI_RETURN_CODE_ID");
没有成功 D: