what version of nhibernate are you using?

2010/9/9 PLen <[email protected]>

> Hello,
>
> I have a similar problem as other posts I have seen in that I hav ea
> table with a BLOB and I do not want to load the byte[] in the object
> until I ask for it.  I found the following article recently which
> indicted that lazy loading of properties is now available for
> NHibernate:
>
>
> http://ayende.com/Blog/archive/2010/01/27/nhibernate-new-feature-lazy-properties.aspx
>
> I have tried this (adding lazy=true) but the SQL still shows that the
> BLOB field is being retrieved.  I assume this capability really does
> exist, so it must be my environment. Here is what I have:
>
> 1) I am using .NET 3.5 (Visual Studio 2008) and C#.
>
> 2) I imported (as references) the Castle.Core.dll,
> Castle.DynamicProxy2.dll, and the NHibernate.ByteCode.Castle.dll
> files.
>
> 3) My class file looks like:
>
> public class RptSource {
>        public RptSource() { }
>        public virtual long SourceId { get; set; }
>        public virtual RptSourceGroup RptSourceGroup { get; set; }
>        public virtual string Name { get; set; }
>        public virtual byte[] Body { get; set; }
>        public virtual string SourcePath { get; set; }
>  }
>
> 4) My mapping files looks like:
>
> <hibernate-mapping assembly="IcebergMain"
> namespace="IcebergMain.Domain" xmlns="urn:nhibernate-mapping-2.2">
>  <class name="RptSource" table="RPT_SOURCE" lazy="true" >
>    <id name="SourceId" type="Int64" column="SOURCE_ID">
>      <generator class="sequence">
>        <param name="sequence">RPT_SOURCE_SEQ</param>
>      </generator>
>    </id>
>    <many-to-one name="RptSourceGroup" column="GROUP_ID" />
>    <property name="Name" column="NAME" />
>    <property name="Body" column="BODY" lazy="true"/>
>    <property name="SourcePath" column="SOURCE_PATH" />
>  </class>
> </hibernate-mapping>
>
> 5) My query looks like:
>
> RptSource src = session.CreateQuery("from RptSource s where s.SourceId
> = :id")
>                    .SetParameter("id", sourceid)
>                    .UniqueResult<RptSource>();
>
> 6) The SQL for the query looks like:
>
> select rptsource0_.SOURCE_ID as SOURCE1_6_, rptsource0_.GROUP_ID as
> GROUP2_6_, rptsource0_.NAME as NAME6_, rptsource0_.BODY as BODY6_,
> rptsource0_.SOURCE_PATH as SOURCE5_6_ from RPT_SOURCE rptsource0_
> where rptsource0_.SOURCE_ID=:p0;:p0 = 107
>
> As you can see, the BODY was returned.  Not sure what I am missing to
> get this to work.
>
> Any thoughts would be greatly appreciated.
>
> Thanks - Peter
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
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.

Reply via email to