tags:

views:

230

answers:

1

I'm not sure how to explain this. So here goes...

I'm trying to fit the method for lazy loading blobs as described here but I'm stuck with only one table.

I have a schema (fixed, in a legacy system) which looks something like this:

MyTable
   ID int
   Name char(50)
   image byte

This is on Informix, and the byte column is a simple large object. Now normally I would query the table with "SELECT ID, Name, (image is not null) as imageexists..." and handle the blob load later.

I can construct my object model to have two different classes (and thus two different map definitions) to handle the relationship, but how can I "fool" nhibernate into using the same table to show this one-to-one relationship?

+2  A: 

Short answer: you can't.

You either need to map it twice or (my preference) create a DTO that has the fields you want. In HQL you'd do something like:

select new MyTableDTO(t.ID, t.name) from MyTable t
Stuart Childs
I'm not sure I understand the Data Transfer Object idea. I'll try to apply the idea from the hibernatingrhinos post and map to the same table.
hometoast