views:

122

answers:

2

Say I have a Queue table and a Job table. In the Job table there is a foreign key column QueueId for the Queue table, i.e.

Queue.Id <-- Job.QueueId

Using Fluent NHibernate it is pretty straightforward to map this to a property in the Queue class, i.e.

/* QueueMap */
HasMany(x => x.Jobs)
   .KeyColumnNames.Add("QueueId");

But assume I have a very good reason to have a class inbetween, say something like:

public class Queue 
{
    public Group Group { get; set; }
}

public class Group
{
    public IList<Job> Jobs { get; private set; }
}

Then I need to map this using a Component, i.e.

/* QueueMap */

Component(
    x => x.Group,
    y => y.HasMany(x => x.Jobs).KeyColumnNames.Add("QueueId")
);

When I do this I get the following:

{"could not initialize a collection: 
[Queue.Group.Jobs#832fc413-c282-48e8-8cb6-d2a70b0b8de4]
[SQL: SELECT values0_.QueueId as QueueId1_, values0_.Id as Id1_, values0_.Id 
 as Id16_0_, (....) FROM dbo.Jobs values0_ WHERE values0_.QueueId=?]"}

Any idea as to what I'm doing wrong...

A: 

Solved. This was caused by a mapping problem in the JobMap.

veggerby
A: 

Hi, I am currently sitting with same problem that you described here. You state that you fixed the problem by changing something in the JobMap. Could you possibly tell me what that change was??

Regards.

chantel