Uploaded image for project: 'NHibernate'
  1. NHibernate
  2. NH-1722

property-ref for columns in a composite key

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1.0.Alpha1
    • Fix Version/s: None
    • Component/s: Core

      Description

      Hi,
      if you map a relation or collection you can use the property-ref attribute to make NHibernate work with legacy data. That's very useful and works as it shoudl. But in my current project nearly all tables have composite ids and relations also use them. As far as I know it is not possible to use the property-ref attribute on the columns of those composite ids. So many relations in this legacy database can't be mapped by NHibernate due to the lack of this functionality...

      I would really appreciate the possiblity of telling NHibernate to take the property-ref attribute in composite ids...

      The mapping for that could be like the following I think:

      <bag name="MyCollection" table="COLL" cascade="none" inverse="true">
      	<key>
      		<column name="CUSTOM_COL" property-ref="CustomColumn" />
      		<column name="ID2" />
      	</key>
      	<one-to-many class="MyCollection" />
      </bag>
      

      For this example you can imagine that the table holding that collection has a few columns (e.g. CUSTOM_COL) and the composite id with the columns ID1 and ID2. The table COLL has the composite id of CUSTOM_COL and ID2...

      I know many projects that have such a legacy structure and it would be very nice if you could add the described functionality to support those projects...

      Thanks

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            ggeurts Gerke Geurts added a comment -

            Hibernate supports this functionality by grouping <property> elements that form a alternative key in a named <properties> element. The collection <key> element can then have a property-ref attribute that refers to the name of the <properties> group. So this issue comes down to porting existing Hibernate functionality to NHibernate.

            Show
            ggeurts Gerke Geurts added a comment - Hibernate supports this functionality by grouping <property> elements that form a alternative key in a named <properties> element. The collection <key> element can then have a property-ref attribute that refers to the name of the <properties> group. So this issue comes down to porting existing Hibernate functionality to NHibernate.

              People

              • Assignee:
                Unassigned
                Reporter:
                typhos Manuel Rennecke
              • Votes:
                17 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Who's Looking?