Date: Wed, 25 Jun 2008 14:21:32 +0200
From: gustavo...@gmail.com
To: nhu...@googlegroups.com
Subject: [nhusers] Re: A first chance exception of type 'NHibernate.MappingException' occurred in NHibernate.dll
From: dag...@hotmail.com
To: nhu...@googlegroups.com
Subject: [nhusers] Re: A first chance exception of type 'NHibernate.MappingException' occurred in NHibern
Date: Wed, 25 Jun 2008 12:36:18 +0000
</html
Date: Wed, 25 Jun 2008 15:53:01 +0200
<br
I have the same problem with a number of mappnigs,
Date: Wed, 25 Jun 2008 16:15:25 +0200
<br
Date: Wed, 25 Jun 2008 12:02:14 -0300
From: fabio...@gmail.com
To: nhu...@googlegroups.com
Subject: [nhusers] Re: A first chance exception of type 'NHibernate.MappingException' occurred in NHibern
I mean, if I have a number of my persistable classes that are raising the same exception, that same exception is:
property not found: id on entity ncontinuity2.core.domain.DifferentClassname
Not me, I have unit tests for all my classes so your point is incorrect.
>> Who write a lot of mappings at the same time without a little CRUD test for each class ?
In fact it is only in the output window when I run my tests do I see the exception. It is not being bubbled up so on the surface it is not stopping me, I just want to know how this exception is
Can you explain how it is innapropriate. I think for Guid, my unsaved-value is completelly correct, ie and empty Guid.
>> P.S. The mapping contain another example of inappropriate unsaved-value usage.
Date: Wed, 25 Jun 2008 13:31:42 -0300
From: fabio...@gmail.com
To: nhu...@googlegroups.com
Subject: [nhusers] Re: A first chance exception of type 'NHibernate.MappingException' occurred in NHibern
I also get a lot of these MappingException:s thrown at start up. The method that’s causing most of these first chance exceptions (MappingException: “property not found”) for me are AbstractPropertyMapping.HasNonIdentifierPropertyNameId(….) that relies on try/catch making it decision.
Personally I haven’t really cared much about it myself though, even though it’s a bit annoying J
/Roger
--
Fabio Maulo
</html
Date: Wed, 25 Jun 2008 21:44:26 +0200
From: gustavo...@gmail.com
Fabio Maulo<br
Subject: [nhusers] Re: A first chance exception of type 'NHibernate.MappingException' occurred in NHibern
Date: Wed, 25 Jun 2008 23:22:22 +0200
From: Roger...@teleopti.com
To: nhu...@googlegroups.com
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.
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.
If no one here can give a clear answer why it should be handled this way, please step code and send a patch for it J
</html
Date: Thu, 26 Jun 2008 11:54:52 +0300
From: aye...@ayende.com
Never once did I post or even insinusate that my bug is life threatening or in anyway of the fashion :"NHIBERNATE BUGZ!! URGENT",
As I have stated now a few times, the bug is not being bubbled up.
I just would like to better understand why.
If Fabio finds my post below him (as he very much sounded like), then please do not answer.
I am not the first person to post with this problem but the response was rude.
<< If you don't have a property
named "ïd" an exception is trowed and catch internally by NH (your
app don't receive the exception).
Is this your case ?>>
I’m sure Paul will reply himself, but I guess this is what his subject said (“a first chance exception”).
FYI – the same will happen even if your identifier/property is called id (maybe only if it’s mapped to a field, I don’t know?). There are quite many exceptions being thrown internally (~100 in our app) at start up which may start developers wondering what’s going on.
Keep up the great work!
From: nhu...@googlegroups.com
[mailto:nhu...@googlegroups.com] On Behalf Of Fabio Maulo
Sent: den 26 juni 2008 16:17
To: nhu...@googlegroups.com
Subject: [nhusers] Re: A first chance exception of type
'NHibernate.MappingException' occurred in NHibern
Paul.
I'm sure Paul will reply himself, but I guess this is what his subject said ("a first chance exception").
FYI – the same will happen even if your identifier/property is called id (maybe only if it's mapped to a field, I don't know?).
There are quite many exceptions being thrown internally (~100 in our app) at start up which may start developers wondering what's going on.
Date: Thu, 26 Jun 2008 09:38:06 -0300
From: fabio...@gmail.com
To: nhu...@googlegroups.com
Subject: [nhusers] Re: A first chance exception of type 'NHibernate.MappingException' occurred in NHibern
Date: Thu, 26 Jun 2008 10:45:30 -0300
From: fabio...@gmail.com
To: nhu...@googlegroups.com
Subject: [nhusers] Re: A first chance exception of type 'NHibernate.MappingException' occurred in NHibern
Btw (on the danger of teling nothing new …), you can hook on those exceptions in VS 2005. Debug -> Exceptions and then add a new CLR exception “NHibernate.MappingException”. If you have the debug symbols for NHibernate.dll and the source path is correct, it should stop whenever this exeption is thrown.
Wolfgang
> On Jun 26, 11:02 am, "Roger Kratz" <Roger.Kr...@teleopti.com> 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