Hudson-

I have a similar implementation of multiple databases per ASP.NET session (
http://is.gd/uk5J) based on Russell Thatcher's bug/patch.  That part of it
is working just fine.

If both data systems were similar, I could understand mapping both, but
they're totally segregated data systems (one if our primary business student
system, the second a bolt-on application we're developing).  The primary
business system (in assembly A) is a read-only connection to Oracle; the
second is a read/write to SQL Server 2005 (in assembly B).

I opened up our framework library and allowed the mappings to be visible and
tried the following on Assembly B's fluent configuration:

 .Mappings(mappings => mappings
                                              .FluentMappings

.AddFromAssemblyOf<AssessmentMap>() // Assembly B

.AddFromAssemblyOf<SchoolMap>()); // Assembly A

That resolves the compile time issue; however, when it tries to build the
object, it thinks that the school map data tables are inside of the Assembly
B database.

If I try to add multiple Database() and Mappings() calls to the
Fluently.Configure(), it seems to generally get confused and run everything
against the last database/mapping in the tree (which is expected).

The stopgap fix for now is to simply return an int[] of the Ids I need and
use an extension method to take the ids and return a List<School> as
originally intended from the Assembly A.  As long as the Mapping files are
blissfully unaware of objects that are outside their assembly, life seems to
be good.

It brings up an odd point though... there's a lot of things that aren't part
of a "mapped class".

What if I wanted to have a HasManyToMany array of strings?  System.String
isn't a mapped class.  Like I said before, however, it may be (or probably
is) that I'm going about this backwards. ;)

-dl

On Fri, Apr 24, 2009 at 11:29 AM, Hudson Akridge
<[email protected]>wrote:

> Well, your problem isn't just a fluent issue, so you'll want to follow one
> of 
> these<http://codebetter.com/blogs/karlseguin/archive/2009/03/30/using-nhibernate-with-multiple-databases.aspx>
> articles.<http://www.codeproject.com/KB/aspnet/NHibernateMultipleDBs.aspx> 
> Managing
> multiple databases and persisting between them seamlessly in the same
> session, to my knowledge, is a difficult task ;) .
> You probably don't want to use two configurations, you would use one
> configuration (and you can pass it to the
> Fluently.Configure(yourConfiguration) call in order to build your mappings
> on different assemblies) and two session factories.
>
> I have no practical experience doing something like this, so it's possible
> there's another, better, alternative.
>
>
> On Thu, Apr 23, 2009 at 12:07 PM, David R. Longnecker <
> [email protected]> wrote:
>
>> After a day of beating the desk, I figured I'd toss this out and see where
>> I've gone astray. :)
>>
>> I have two fluent configurations... one to our primary business
>> application that contains a mapping to an object (a "school" object) and a
>> second that is for a secondary system I'm developing that needs to create a
>> list of objects based on the mapping from that primary app.
>>
>> In the entity object "BuildingUser":
>>
>> public virtual IList<School> BuildingUserSchools { get; set; }
>>
>> School is part of another database; that database is being initialized
>> prior to this secondary database, so the mapping files for "School" should
>> be available.
>>
>> In the BuildingUserMap file:
>>
>> HasManyToMany(x => x.BuildingUserSchools)
>>                 .WithTableName("BuildingUserSchools")
>>                 .WithParentKeyColumn("Id")
>>                 .WithChildKeyColumn("BuildingUserId")
>>                 .FetchType.Join();
>>
>> I've tried explicitly setting ".CollectionType(typeof (School))" to no
>> avail.  It seems there should be a property to say "when building a school
>> object, you need to know the BuildingUserSchools.SchoolId column..."
>>
>> When initializing the fluent configuration, the mappings are using
>> standard fluent mappings:
>>
>>  .Mappings(mappings => mappings
>>                                 .FluentMappings
>>                                     .AddFromAssemblyOf<AssessmentMap>());
>>
>> Trying to init that configuration, however, returns the following error:
>>
>> "An association from the table BuildingUserSchools refers to an unmapped
>> class: USD259.Domain.Sis.School"
>>
>> As I mentioned prior, the fluent configuration that maps
>> USD259.Domain.Sis.School is initializing just fine; I can return School
>> objects without any issues; however, it seems the second "Assessment"
>> configuration isn't aware that the first exists.
>>
>> So the question:  Is there a way to tell one fluent configuration that
>> another, already initialized mapping configuration is available and to use
>> it's mappings for objects? e.g.
>>
>> (fluent config #1) NewApplication.Assessment.BuildingUserSchools
>>
>> is a
>>
>> (fluent config #2) IList<USD259.Domain.Sis.School>
>>
>> I keep having this sinking feeling that for each of the fluent mappings to
>> be "aware" of each other, they each have to map each other...
>>
>> Is there a better way to do this?
>>
>> Thanks in advance!
>>
>> -dl
>>
>> David R. Longnecker
>> Blog <http://blog.tiredstudent.com/> | 
>> Twitter<http://www.twitter.com/dlongnecker>|
>> LinkedIn <http://www.linkedin.com/in/davidlongnecker>
>>
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to