Duplicated db columns in result set

99 views
Skip to first unread message

Roger Kratz

unread,
Nov 24, 2008, 5:59:20 AM11/24/08
to nhu...@googlegroups.com

Hi

 

When eagerly loading collections using ICriteria, I’ve noticed that some columns sometimes are returned multiple times. I haven’t had a closer look what makes this happen though.

 

Before digging deeper into this (and creating a JIRA ticket), I just want to check if this is by design (cannot see why, but…)?

 

Eg, generated sql when using SetFetchMode(“xCollection”, FetchMode.Join)….

 

Select

this_.Id

[…]

Xcollec2_.Id as Id3_,

Xcollec2_.Id as Id96_0_,

[…]

 

/Roger

Ayende Rahien

unread,
Nov 24, 2008, 6:08:12 AM11/24/08
to nhu...@googlegroups.com
Once is when it is used as the id of the entity
Second when it is used as the FK reference of the association

Roger Kratz

unread,
Nov 24, 2008, 6:12:37 AM11/24/08
to nhu...@googlegroups.com

Hmm... Thanks, but… Why?

Roger Kratz

unread,
Nov 24, 2008, 8:06:30 AM11/24/08
to nhu...@googlegroups.com

FYI

 

There are other situation where data is sent over the wire as multiple, identical columns…

 

* Bidirectional refs will have two identical columns

* Indexed collections (at least <list>) will have two identical index columns

 

I’ll be happy to expose these things in some unit tests. Should I do this?

 

 

From: nhu...@googlegroups.com [mailto:nhu...@googlegroups.com] On Behalf Of Ayende Rahien
Sent: den 24 november 2008 12:08
To: nhu...@googlegroups.com
Subject: [nhusers] Re: Duplicated db columns in result set

 

Once is when it is used as the id of the entity

Ayende Rahien

unread,
Nov 24, 2008, 2:23:20 PM11/24/08
to nhu...@googlegroups.com
The issue here is that NH has no guaratees that they will be the same column.

Roger Kratz

unread,
Nov 24, 2008, 2:45:18 PM11/24/08
to nhu...@googlegroups.com

I understand. But on the other hand – NH knows the column names at run time, doesn’t it? I wouldn’t/can’t argue whether it’s hard or easy to implement, but still… The info is there and it would be _possible_ for NH to know when it’s producing duplicated columns and later reuse the same data eg in bidirectional refs. Or?

 

Anyhow – now I know it’s not a bug. Thanks.

Ayende Rahien

unread,
Nov 24, 2008, 2:50:33 PM11/24/08
to nhu...@googlegroups.com
The problem is that trying to do this logic is complex and unfriendly.
The cost for the user is an extra column that is being sent, but that is not going to cost any additional I/O.

Roger Kratz

unread,
Nov 24, 2008, 2:59:39 PM11/24/08
to nhu...@googlegroups.com

In normal queries, the network traffic is defiantly neglectable, yes.

I just noticed this today when we were looking at/trying to minimize some big queries for our fat clients where lots of data needs to be transferred over the wire. I’m totally aware there are more “important” stuff to look at than duplicated columns, but I honestly thought it was a bug when I first looked at it.

 

Thanks for your input.

Jan Benny Thomas

unread,
Nov 24, 2008, 2:45:40 PM11/24/08
to nhu...@googlegroups.com

Should NH be able to sometimes find out from the information that is provided witch columns in the mappings that are identical? This sounds like an optimizing issue.

Ayende Rahien

unread,
Nov 24, 2008, 5:25:18 PM11/24/08
to nhu...@googlegroups.com
Honestly, it is not worth the dev time

On Mon, Nov 24, 2008 at 9:45 PM, Jan Benny Thomas <jan.t...@lyse.net> wrote:

Should NH be able to sometimes find out from the information that is provided witch columns in the mappings that are identical? This sounds like an optimizing issue.

 

From: nhu...@googlegroups.com [mailto:nhu...@googlegroups.com] On Behalf Of Ayende Rahien


Sent: 24. november 2008 20:23

Jan Benny Thomas

unread,
Nov 24, 2008, 7:07:52 PM11/24/08
to nhu...@googlegroups.com

I respect that!

Reply all
Reply to author
Forward
0 new messages