Hibernate version: 2.0.0GA
Mapping documents:
Line Mapping:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Example.Domain" assembly="Example">
<class name="Line" table="LINES">
<id name="Id" column="ID">
<generator class="native" />
</id>
<many-to-one name="Start" class="EndPoint" column="START" cascade="save-update" not-found="ignore" />
<many-to-one name="End" class="EndPoint" column="END" cascade="save-update" not-found="ignore" />
</class>
</hibernate-mapping>
EndPoint Mapping:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Example.Domain" assembly="Example">
<class name="EndPoint" table="ENDPOINTS">
<id name="Id" column="ID" >
<generator class="native" />
</id>
<bag name="Lines" inverse="true">
<!-- THIS IS WHERE I'M STUCK
it contains ALL lines that use this EndPoint
as either a Start or an End !>
</bag>
</class>
</hibernate-mapping>
Name and version of the database you are using: SQLite
What I'm looking for (and can't find in the docs or online) is how to map a collection on the EndPoint class to ALL lines that reference it. No matter if the reference is as the Line.Start or Line.End. So essentially I need a many-to-one-properties type association. Is this possible in NHibernate
Now, I'm fairly confident that if I wanted to change my existing code to meet the needs of my ORM I could change the EndPoint to have two separate lists, one for lines that use the EndPoint in Start and one for the Lines that use the EndPoint for an End. But, I have quite a bit of code to change and, while it's better than having dependencies in my code, I'd rather not start changing code to meet the needs of the ORM?
Any hints/insights on how to bend NHibernate to my will are greatly appreciated! Thanks in advance!!
edit: removed the link at the top to the 'read first' link
|