and we have tests on it.
YAHOO!!!
I have learned something new, about NH, today!!!

With optional="true" even the fetch="select" should work.

On Fri, Dec 3, 2010 at 5:19 PM, Fabio Maulo <[email protected]> wrote:

> CONGRATULATION!!!
> You have discovered one thing I don't know about NH.
> Thanks you very much!!!
>
>
> On Fri, Dec 3, 2010 at 5:13 PM, David McClelland <
> [email protected]> wrote:
>
>> I did figure out how to get use only one SELECT statement by
>> incorporating a LEFT JOIN into the query.  I used the optional
>> attribute instead of the fetch attribute:
>>
>> <join table="EntityAddress" optional="true">
>>
>> So...   now the nicely clean EntityAndPrimaryAddress is returned even
>> if there is only an Entity with no corresponding address.
>>
>> - David
>>
>>
>> On Dec 3, 12:51 pm, Jason Meckley <[email protected]> wrote:
>> > you could map the address to a private field and expose those
>> > properties on the EntityAndPrimaryAddress object. the public api
>> > remains clean. the "ugly code" remain encapsulated within the
>> > EntityAndPrimaryAddress object.
>> >
>> > public class EntityAndPrimaryAddress
>> > {
>> >     private Address address;
>> >
>> >         public virtual int EntityId { get; set; }
>> >         public virtual int CreatedBy { get; set; }
>> >         public virtual DateTime CreatedDate { get; set; }
>> >         public virtual int ModifiedBy { get; set; }
>> >         public virtual DateTime ModifiedDate { get; set; }
>> >         public virtual int UpdateCounter { get; set; }
>> >
>> >         public virtual bool IsPrimary
>> >         {
>> >                 get {return address.IsPrimary;}
>> >                 set {address.IsPrimary = value;}
>> >         }
>> >     ... the rest of the properties.
>> >
>> > }
>> >
>> > i don't see what other options you have. when working with a legacy
>> > database details of the database will spill into the domain. the only
>> > way to prevent this is to refactor the database along with the code.
>> >
>> > something else to consider is why querying with a single select is a
>> > problem.
>> >
>> > On Dec 3, 1:06 pm, Fabio Maulo <[email protected]> wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > sure.
>> > > but you know... the <join> is only a "licenza poetica" of ORM for
>> legacy DB
>> > > not designed following ORM.
>> >
>> > > When you say that the state of an entity is spanned in two tables it
>> mean
>> > > exactly that to have the state of an entity NH have to join (inner)
>> two
>> > > tables; there isn't another option, NH have to read all properties.
>> > > Perhaps you can try using lazy=true in each property and see what will
>> > > happen, perhaps it will work but AFIK we don't have a specific test
>> for this
>> > > situation.
>> >
>> > > P.S. ORM= Object Relational *Mapping*
>> >
>> > > On Fri, Dec 3, 2010 at 2:36 PM, David McClelland <
>> [email protected]
>> >
>> > > > wrote:
>> > > > But a <one-to-one> won't give me the nicely-flattened entity that
>> I'm
>> > > > interested in:
>> >
>> > > >    public class EntityAndPrimaryAddress
>> > > >    {
>> > > >        public virtual int EntityId { get; set; }
>> > > >        public virtual int CreatedBy { get; set; }
>> > > >        public virtual DateTime CreatedDate { get; set; }
>> > > >        public virtual int ModifiedBy { get; set; }
>> > > >        public virtual DateTime ModifiedDate { get; set; }
>> > > >        public virtual int UpdateCounter { get; set; }
>> > > >        public virtual bool IsPrimary { get; set; }
>> > > >        public virtual string Name { get; set; }
>> > > >        public virtual string Line1 { get; set; }
>> > > >        public virtual string Line2 { get; set; }
>> > > >        public virtual string City { get; set; }
>> > > >        public virtual string State { get; set; }
>> > > >        public virtual string PostalCode { get; set; }
>> > > >    }
>> >
>> > > > --
>> > > > 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]>
>> <nhusers%[email protected]<nhusers%[email protected]>>
>> > > > .
>> > > > For more options, visit this group at
>> > > >http://groups.google.com/group/nhusers?hl=en.
>> >
>> > > --
>> > > Fabio Maulo
>>
>> --
>> 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.
>>
>>
>
>
> --
> Fabio Maulo
>
>


-- 
Fabio Maulo

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