Unhandled MappingException in PersistentUnitRepo:GetPU(Type t)

Description

This problem happens when multiple persistent units are loaded (i.e. when you use more than one nhibernate config file). If you try to persist a type that is not defined in the first PU, it can result in an unhandled MappingException. The problem appears to be the following code from PersistentUnitRepo:GetPU(Type t):

foreach (PersistenceUnit pu in persistenceUnits)
{
ISessionFactoryImplementor sfi = (ISessionFactoryImplementor) pu.SessionFactory;
if (sfi.GetEntityPersister(t) != null)
{
return pu;
}
}

With NHibernate 2.0.0.3001, GetEntityPersister() throws a MappingException if the persister cannot be found.

The attached patch just surrounds the call with try/catch.

Environment

None

Attachments

1

Activity

Show:

Kailuo Wang 
September 9, 2008 at 9:08 PM

fixed by using a different method overload.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created September 2, 2008 at 2:14 AM
Updated September 9, 2008 at 9:08 PM
Resolved September 9, 2008 at 9:08 PM
Who's Looking?