From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-31 12:12:13
|
[ http://216.121.112.228/browse/NH-1050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo resolved NH-1050. ----------------------------- Resolution: Fixed Fix Version/s: 3.2.0Beta2 > Unidirectional One To Many Without Nullable Foreign Key > ------------------------------------------------------- > > Key: NH-1050 > URL: http://216.121.112.228/browse/NH-1050 > Project: NHibernate > Issue Type: Improvement > Components: Core > Affects Versions: 1.2.0.GA > Reporter: Colin Jack > Priority: Major > Fix For: 3.2.0Beta2 > > > Especially with a legacy database we need to work with the database design that we have, with a view to future redesign. NHibernate seems to miss two features that would make this work really well: > 1) Mapping inheritance at the <component> level would be a big advantage > 2) A way to handle unidirectional many-one, with the foreign key in the one end causes us to make that key column nullable which is troublesome. > Its the second issue that I wanted to raise. We get into situations where the ID of the parent (one) is in the child (many) either because our database designers want that approach or because thats the way the database was originally designed. There seem to be two solutions: > 1) Use a bidirectional relationship - We don't want to design our associations just so that we can use NHibernate. > 2) Make the foreign key nullable. > It would be nice if we could handle this without making the foreign key nullable, even if we had to bake into the mapping more knowledge of our domain model (such as that the child is never saved except by the parent). So if we had an Order with Items in it then if we could say that Items are only saved from the Order (the Order being the aggregate root) then I would have thought you could avoid making the foreign key in Item nullable? > This link covers the sort of issue I'm discussing: > http://forum.hibernate.org/viewtopic.php?t=948277&view=next&sid=ec0773380349d434719a525332b9c962 -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |