At 11.29 24/10/2007, Sandy Young wrote: >Hi, Andrea > > >Thanks you very much for your reply! > >But my work is different from yours. In my project, object subj to object reg >is one-to-many relationship. So subj is a single object, not a IList.
that should make no difference because a single object is a particular case of a list from the perspective of iBatis lazy load. I can't see anything wrong in your map except this little typo (note the space in the select attribute: <result property="Subj" column="SubjID" lazyLoad="true" select=" Subj.Find" /> but if Subj.Find is a valid statement mapped to the same Type of the property Subj of class Reg, I can't see anything wrong. Remember that the object is lazy-loaded when a property of it is actually accessed, that is: Reg reg = ... //load from Database via ibatis, lets assume reg is not null now. Reg newReg = new Reg(); //instantiate a new reg object (just for the example) newReg.Subj = reg.Subj //this DOES NOT fire lazy load int dummy = reg.Subj.SubjId //this DOES fire lazy load, assuming SubjId is a property of class Subj Andrea >My configs are just like below: > >////In Reg.config: > ><resultMaps> > <resultMap id="SelectAllResult" class="Reg"> > <result property="SeqId" column="SeqId"/> > <result property="UserID" column="UserID"/> > <result property="HoldScoreKind" column="HoldScoreKind"/> > <result property="IsTrain" column="IsTrain"/> > <result property="SubjID" column="SubjID"/> > <result property="FeeAffirm" column="FeeAffirm"/> > <result property="AffirmTime" column="AffirmTime"/> > </resultMap> > <resultMap id="SelectAllResultExtent" class="Reg" > extends="SelectAllResult"> > <result property="User" column="UserID" lazyLoad="true" > select="User.Find" /> > <result property="Subj" column="SubjID" lazyLoad="true" select=" > Subj.Find" /> > </resultMap> > </resultMaps> > >/////In Subj.config: > ><select id="FindAll" resultMap="SelectAllResultExtent"> > SELECT > * > FROM [Subj] > </select> ><select id="Find" parameterClass="int?" resultMap="SelectAllResultExtent" >extends="FindAll"> > WHERE > [Subj].[ID] = #value# > </select> > > Andy > >On 10/24/07, Andrea Tassinari <<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED] > >wrote: >Hi, > >I am currently using DataMapper 1.6.1 and lazy load works great. > >One example: > >1) result Map for object Lotto containing a 1-to-many relationship mapped in >my domain with a List<Cantina> > ><result property="Cantine" column="Id" select="SelectCantinaByLottoId" >lazyLoad="true"/> > >Stupid question: did you specified a resultMap *not* a resultClass in the >select statement? > ><!--Wrong version lazy load not involved --> ><select id="SelectLottoById" parameterClass="string" resultClass="Lotto"> > <include refid="SelectLotto_BaseSQL" /> > <dynamic prepend="WHERE"> > <isParameterPresent>Id = #value#</isParameterPresent> > </dynamic> ></select> > ><!--Correct version lazy load fired --> ><select id="SelectLottoById" parameterClass="string" resultMap="LottoResMap"> > <include refid="SelectLotto_BaseSQL" /> > <dynamic prepend="WHERE"> > <isParameterPresent>Id = #value#</isParameterPresent> > </dynamic> ></select> > > >Hope this helps > >Andrea > >At 10.38 24/10/2007, Sandy Young wrote: > >>When I use DataMapper-1.6.1 instead of DataMapper-1.5.1, I find the lazyload >>function doesn't work. >> If I replace DataMapper-1.6.1 with older DataMapper-1.5.1, it works. >> I find this bug is reported as a bug in >> <<http://ibatis.net>http://ibatis.net><http://ibatis.net>ibatis.net's Issue >> Tracker. >>Is there anybody can fix it? >>Thank you! >> >>My code: >> >>IRegDao dao = new RegDao(); >> Reg reg = dao.Find(1); >> Console.WriteLine("Reg:"); >> Console.WriteLine("SeqId:{0}", reg.SeqId); >> Console.WriteLine("SubjID:{0}\tName:{1}", reg.SubjID, >> <<http://reg.Subj.Name>http://reg.Subj.Name><http://reg.Subj.Name>reg.Subj.Name); >> >>///class Reg >>public partial class Reg >> { >> #region Private Member >> private int? _SubjID; >> #endregion >> >> #region Private Extend Member >> private Subj _Subj; >> #endregion >> >> #region Constructor >> public Reg() >> { >> } >> #endregion >> >> #region Public Properties >> public int? SubjID >> { >> get {return _SubjID;} >> set {_SubjID = value;} >> } >> #endregion >> >> #region Public Extend Properties >> public virtual Subj Subj >> { >> get { return _Subj; } >> set { _Subj = value; } >> } >> #endregion >> } >> >> >>No virus found in this incoming message. >>Checked by AVG Free Edition. >>Version: 7.5.503 / Virus Database: 269.15.8/1089 - Release Date: 23/10/2007 >>19.39 > > > > >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.5.503 / Virus Database: 269.15.8/1089 - Release Date: 23/10/2007 >19.39

