I have a header table in my database that looks like this (simplified):
"job_hdr"
job_id     int   pk
started    date  
notes      text

"job_items"
job_id     int   pk
job_type   int   pk
quantity   int

My internal classes are similar, with the header containing an 
IList<JobItem> and the JobItem containing the Header. All properties are 
set Virtual.
The maps are as follows:

public class JobHeaderMap : ClassMap<JobHeader>
{
        public JobHeaderMap ()
        {
                Table("job_hdr");
 
                Id(x => x.ID, "job_id");                //Auto-increment
 
                Map(x => x.Started, "started");
                Map(x => x.Notes, "notes");
 
                HasMany(x => x.Items)
                        .KeyColumn("job_id")
                        .Inverse()
                        .Cascade.All();
        }
}


public class JobItemMap : ClassMap<JobItem>
{
        public JobItemMap()
        {
                Table("job_items");
 
                Id(x => x.JobType, "job_type").GeneratedBy.Assigned();
 
                Map(x => x.Quantity, "quantity");
 
                References(x => x.JobHeader, "job_id").Cascade.None();
        }
}


When I use my maps, it seems that some of the job_items are overwritten 
with each update, and the only thing I can think is that it doesn't know 
that job_type is also a key.
I've been reading about composite_ids and other mappings, but I'm 
relatively new to all of this.

I'm having quite a few issues figuring out how to properly map this setup, 
any help would be most appreciated!

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fluent-nhibernate+unsubscr...@googlegroups.com.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
Visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to