First off: Hi and nice to see that NHibernate now has it's own spot on
the Internet! After some effort to compile NHibernate, Spring and
Memcached for our project I have found why our project is giving a lot
of "first chance..." lines in the ouput tab of VS.
I am sorry if this first post comes to you as anything else but
friendly and informative. My only reason for posting here is to
clearify what NHibernate does in this case and ask if this was
actually meant or maybe done unwillingly. I don't see this as a bug
only as something dirty and requiring attention, some day...

> On Jun 26, 11:02 am, "Roger Kratz" <[EMAIL PROTECTED]> wrote:
> AbstractPropertyMapping.HasNonIdentifierPropertyNameId(....) will check
> for a _property_ called "id". When this is not found, an exception is
> thrown. That's why you see all these first chance exceptions. Even if
> your identifier would be called "id" I you will have the same exception
> thrown/caught.

This is because the code throwing the exception is a generic property
lookup function PersistantClass:

1        public Property GetProperty(string propertyName)
2        {
3            IEnumerable<Property> iter = PropertyClosureIterator;
4            Property identifierProperty = IdentifierProperty;
5            if (identifierProperty != null &&
identifierProperty.Name.Equals(StringHelper.Root(propertyName)))
6            {
7                return identifierProperty;
8            }
9            else
10            {
11                return GetProperty(propertyName, iter);
12            }
13        }

What strikes me as odd is that when NHibernate has the identifier
property (line 4) and it is not the same as the one defined in some
struct (line 5) it still wants to look in all the normal properties
(so excluding identifier properties) for the column (line 11). In our
case this is never the case, because we do not use access="field" on
our Id properties nor do we name our identifier property "id". This
gives us about 1632 "first chance" lines in the output tab in VS.
Which increases our startup time with about 100%.

This all is called by the following code:

1       protected void InitIdentifierPropertyPaths(string path,
EntityType etype, string[] columns, IMapping factory)
2       {
3           IType idtype =
etype.GetIdentifierOrUniqueKeyType(factory);
4           string idPropName =
etype.GetIdentifierOrUniqueKeyPropertyName(factory);
5           bool hasNonIdentifierPropertyNamedId =
HasNonIdentifierPropertyNamedId(etype, factory);
             ....

We do have the identifier property name of the Mapping (line 4) but
let's see if the class we map to has a property which is called "id"
but is not an identifier property (line 5). At one hand I can
understand that it wants to look for the property "id" but then either
let us specify our default value for "id" (which is specified in the
struct EntityPersister) in a/some config or don't search for it at
all. Throwing exceptions and not using them (logging or otherwise) is
a bit of a dirty approach. I would make addional functions which
accept another argument, namely the property NHibernate has already
found (line 4) so that NHibernate does not have to throw and uncleanly
catch an exception.

> Unfortunately I haven't had a closer look why this is needed. I have no
> doubt it's there for a reason but of course it would be better if it
> could be handled without relying on catching exceptions.

It would indeed be better. With large applications (with NHibernate
and Spring in our case) the startup time is already a bit long but
because VS logs these unused Exceptions in its output tab the startup
time is doubled if not tripled.
We just moved from NHibernate 1.2 to NHibernate 2.0 and the startup
time has tripled from 20 seconds to nearly 60 seconds.

I hope my post was clear to you, if not don't hesitate to say so.

Greetings,

Hielke Hoeve
Topicus Onderwijs BV, Netherlands

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