using FluentNHibernate.Mapping;

namespace NHibernateHacking {
    public sealed class CustomerMap : ClassMap<Customer> {
        public CustomerMap() {
            Id(x => x.Id).GeneratedBy.GuidComb();
            Map(x => x.Name);
            HasMany(x => x.Orders).Cascade.AllDeleteOrphan()
                                  .Inverse();
//                                  .Fetch.Join();
        }
    }

    public sealed class OrderMap : ClassMap<Order> {
        public OrderMap() {
            Id(x => x.Id).GeneratedBy.GuidComb();
            References(x => x.Customer);
            HasMany(x => x.LineItems).Cascade.AllDeleteOrphan()
                                     .Fetch.Join();
        }
    }

    public sealed class LineItemMap : ClassMap<LineItem> {
        public LineItemMap() {
            Id(x => x.Id).GeneratedBy.GuidComb();
        }
    }
}