Hello, would be very glad if someone could help me out!
Any ideas?.. or tell me at least if single-column-lazy-loading is possible with NHibernate in general or not...
If you need more detailed information tell me.
I am using NHibernate 1.0.4
I have an Object that has some byte[] attributes. When I'm loading the list of all this objects I don't want the byte-Arrays to be loaded. At the moment I am using a query that only asks for the rest of these objects (not the BLOBs) which is not comfortable since it doesn't return my Object's type.
I want these single BLOB database columns to be lazy-loaded when queried and return instances of my objects.
I declared the objects public/virtual as needed for proxying, since lazy-loading of another <one-to-one> relationship works.
I read that it should be possible to mark a property as lazy=true, but it is not possible with the NHibernate version I am using.
Thought it could have s.th. to do with this parent Interface IClonable, but commenting it out, didn't change anything.
MAPPING
<class name="SwProjectBO" table="PROJECTDATA" lazy="true">
<id name="SWConfiguration" type="String">
<column name="SW_CONFIGURATION" sql-type="CHAR(14)"/>
<generator class="assigned" />
</id>
...
<!-- files -->
<property name="SupplementData" type="BinaryBlob">
<column name="SUPPLEMENTDATA" sql-type="BLOB"/>
</property>
<property name="ControllerCode" type="BinaryBlob">
<column name="CONTROLLERCODE" sql-type="BLOB"/>
</property>
<property name="FlashLoader" type="BinaryBlob">
<column name="FLASHLOADER" sql-type="BLOB"/>
</property>
<property name="FlashLoader2" type="BinaryBlob">
<column name="FLASHLOADER2" sql-type="BLOB"/>
</property>
<property name="EepromData" type="BinaryBlob">
<column name="EEPROMDATA" sql-type="BLOB"/>
</property>
<property name="RamData" type="BinaryBlob">
<column name="RAMDATA" sql-type="BLOB"/>
</property>
...
</class>
METHOD
Code:
public SwProjectBO[] GetProjectList(){
IQuery q = transactionManager.GetCurrentSession().CreateQuery("select from SwProjectBO ");
IList myList = q.List();
SwProjectBO[] resultArray = new SwProjectBO[myList.Count];
int i=0;
foreach (SwProjectBO pbo in myList){
resultArray[i] = pbo;
i++;
}
return resultArray;
}
PERSISTENT CLASS
Code:
public class SwProjectBO : ICloneable {
private static readonly ILog logger = LogManager.GetLogger(typeof(SwProjectBO));
//properties
#region local declaration of properties
...
//metadata
private string itsSWConfiguration = string.Empty;
...
//files
private byte[] itsControllerCode = new byte[0];
private byte[] itsFlashLoader = new byte[0];
private byte[] itsFlashLoader2 = new byte[0];
private byte[] itsEepromData = new byte[0];
private byte[] itsRamData = new byte[0];
private byte[] itsSupplementData = new byte[0];
...
#region Accessors of properties
//accessors of properties
public virtual string SWConfiguration {
get {return this.itsSWConfiguration;}
set {this.itsSWConfiguration = value;}
}
... all accessors of this class are virtual
//constructor
public SwProjectBO() {}
}
If someone could tell me if it is generally possible and how, it would be a great help.