Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fluent nHibernate Join is doing insert into joined table

I am trying to use join to pull in a single property from another table, which doesn't have a mapping. My problem is that when I create a new instance of my mapped entity and save it I get an error about trying to insert into my unmapped table (it's trying to insert null into a not null column). I thought using .ReadOnly() would stop nhibernate from trying to insert into my unmapped table but that doesn't seem to work.

My mapping looks like this:

        // Join _UnMapped table with Mapped table to get the property
        Join("_UnMapped", x =>
            {
                x.Fetch.Join();
                x.KeyColumn("UnMappedFK");
                x.Map(y => y.Property, "Property")
                    .Not.Nullable()
                    .ReadOnly();
            });

I have thought about creating a view and mapping to that to get this property, but if I can I would rather do it through a mapping. Any help (or an explanation on how join is supposed to work) would be greatly appreciated!

like image 407
Ben Tidman Avatar asked Jul 26 '11 21:07

Ben Tidman


1 Answers

Use x.Inverse();.

Here is some documentation about join.

like image 72
cremor Avatar answered Sep 18 '22 01:09

cremor