These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: lazy loading BLOB-column NHibernate: possible or not?
PostPosted: Mon Jun 18, 2007 7:22 am 
Newbie

Joined: Mon Jun 18, 2007 6:30 am
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.