ok... then is easy You can map the two properties as access="readonly" and in its getter you can read your collection to get LastXYZ. The two properties will be saved as denormalized properties and you can use it in any queries.
If you want you can map it as access="nosetter.camelcase" and implements the getter in order to read from collection when the private field is null (Note: when you change the collection adding, removing or changing a member you should "reset" the LastXYZ). In both case what will result "denormalized" is the DB but in your model everything will be auto-protected... in practice the same you are doing with Invoice.TotalAmmount 2010/2/23 Chris B <[email protected]> > There is also a list of all previous versions in the > Header.AllVersions property. I had forgotten that I omitted it in my > original post. The only use case where this is loaded is when a user > requests to view the version history. > > The LatestVersion and LatestApprovedVersion references are mainly for > efficiency. Most use cases involve either displaying/mutating the > data of the LatestVersion or reading the data of the > LatestApprovedVersion. It would be great if we could selectively load > those two versions (on demand) without having to load all versions. > > Here is an updated entity definition: > > public class Header > { > public virtual int HeaderId { get; set; } > public virtual Version LatestVersion { get; set; } > public virtual VersionLatestApprovedVersion { get; set; } > public virtual List<Version> AllVersions { get; set; } > // other members > } > > public class Version > { > public virtual int VersionId { get; set; } > public virtual Header Header { get; set; } > // other members > } > > Does that help to clarify? > > On Feb 23, 11:15 am, Fabio Maulo <[email protected]> wrote: > > you are showing only LatestVersion and LatestApprovedVersion > > where are previous ? > > > > 2010/2/19 Chris B <[email protected]> > > > > > > > > > Hello, > > > > > I am trying to create a mapping file for entities which look like the > > > following: > > > > > public class Header > > > { > > > public virtual int HeaderId { get; set; } > > > public virtual Version LatestVersion { get; set; } > > > public virtual VersionLatestApprovedVersion { get; set; } > > > // other members > > > } > > > > > public class Version > > > { > > > public virtual int VersionId { get; set; } > > > public virtual Header Header { get; set; } > > > // other members > > > } > > > > > The database looks almost exactly like this, with the obvious > > > difference being that instead of object references there are foreign > > > keys for the latest/latest approved versions pointing to the VersionId > > > field, and the same for the Header and HeaderId. The table for the > > > header does allow both the latest and latest approved version ids to > > > be null to allow the Header records to be inserted before the Versions > > > are created. The insert proc for the Version table takes care of > > > updating the Header.LatestVersionId to point at newly inserted version > > > record. > > > > > I have thus far been unsuccessful in creating mapping files for this > > > pattern, the sticking point being the LatestVersion and > > > LatestApprovedVersion properties. I'm pretty new to NHibernate, so I > > > apologize if this is answered in another thread. > > > > > Any help is much appreciated. Thanks in advance. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "nhusers" group. > > > To post to this group, send email to [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]<nhusers%[email protected]> > <nhusers%[email protected]<nhusers%[email protected]> > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/nhusers?hl=en. > > > > -- > > Fabio Maulo > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- Fabio Maulo -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
