I'm trying to create a many-to-many relationship with a slightly more complex composite key.
According to the Hibernate docs, this should be possible:
"23.4.3. Many-to-many with shared composite key attribute"
http://www.hibernate.org/hib_docs/v3/re ... manytomany
Doesn't really work with NHibernate (1.0.2), so I suspect I'm doing something wrong.
I have the following table setup.
A - pk( a_id )
B - pk( b_id )
AB_LINK - pk( a_id, b_id, type_code )
Trying to use the following
bag in A.hbm.xml
Code:
<bag name="bees" table="AB_LINK">
<key>
<column name="a_id"/>
</key>
<many-to-many class="B">
<column name="b_id"/>
<column name="type_code"/>
<formula>'ACTIVE'</formula>
</many-to-many>
</bag>
yields the following exception:
Code:
TestCase 'SampleTest.Test1' failed: NHibernate.MappingException : The element 'urn:nhibernate-mapping-2.0:many-to-many' has invalid child element 'urn:nhibernate-mapping-2.0:formula'. Expected 'urn:nhibernate-mapping-2.0:column'. An error occurred at , (16, 6).
----> System.Xml.Schema.XmlSchemaException : The element 'urn:nhibernate-mapping-2.0:many-to-many' has invalid child element 'urn:nhibernate-mapping-2.0:formula'. Expected 'urn:nhibernate-mapping-2.0:column'. An error occurred at , (16, 6).
C:\projects\lib\nhibernate\src\NHibernate\Cfg\Configuration.cs(402,0): at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream)
C:\projects\lib\nhibernate\src\NHibernate\Cfg\Configuration.cs(574,0): at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly, Boolean skipOrdering)
C:\projects\lib\nhibernate\src\NHibernate\Cfg\Configuration.cs(528,0): at NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly)
C:\projects\lib\nhibernate\src\NHibernate\Cfg\Configuration.cs(509,0): at NHibernate.Cfg.Configuration.AddAssembly(String assemblyName)
...
If I'm reading the error right it's saying that NHibernate doesn't support
formulas on
many-to-many even though Hibernate says it does.
If that is correct - do I have a work-around for what I'm trying to do? If not, what am I doing wrong?
Thank you all very much.
philip