ComponentCompositeIdentifier example

Showing 1-2 of 2 messages
ComponentCompositeIdentifier example Trygve Lorentzen 4/5/11 4:45 AM
Hello, is there any examples of using the ComponentCompositeIdentifier
mapping for a composite Id? I can't find any when searching this group
or google. I found this post with something similar although I don't
use interfaces for the key components.

Entity: Company
int Id
string Name
PostalPlace postalPlace

Entity: PostalPlace
PostalPlaceKey Key
string Name
bool IsMailBox

ValueObject: PostalPlaceKey
string CountryCode
string PostalCode
Re: ComponentCompositeIdentifier example Trygve Lorentzen 4/7/11 9:43 AM
                        Table("companies");
                        Schema("xxxx");
                        Id(x => x.Id, "companyid").GeneratedBy.Native();
                        Not.LazyLoad();
                        Map(x => x.Name, "name");
                        References(x => x.PostalPlace)
                                .Class(typeof(PostalPlace))
                                .Not.Nullable()
                                .Columns("countrycode", "postalcode")
                                .Fetch.Select()
                                .Cascade.SaveUpdate();

                        Table("postalplace");
                        Schema("xxxx");
                        CompositeId().ComponentCompositeIdentifier<PostalPlaceKey>(pkk =>
pkk.Key)
                                .KeyProperty(x => x.Key.PostalCode, "postalcode")
                                .KeyProperty(x => x.Key.CountryCode, "countrycode");
                        Not.LazyLoad();
                        Map(x => x.IsMailBox, "postbox");
                        Map(x => x.Name, "postalplacename");
                        HasMany(x => x.Companies)
                                .KeyColumns.Add("postalcode", "countrycode")
                                .Inverse()
                                .Cascade.SaveUpdate()
                                .Fetch.Select()
                                .AsBag();
                        Version(x => x.Ts);