It turned out that it wasn't such a big deal to user the composite-id
tag instead.   :-)

The documentation for composite-id did not mention the key-many-to-one
trick and also stated that I had to user a serializable class.
Apparently you do not have to use a serializable class.

So if I do this it works:

<class name="AB">
  <composite-id>
    <key-many-to-one name="A" class="A" column="Aid" lazy="false" />
    <key-many-to-one name="B" class="B" column="Bid" lazy="false" />
  <composite-id>
  <property name="p1" />
  <property name="p2" />
</class>

I could even put a reference to AB on A:
...
<bag name="ABs" inverse="true" cascade="none" lazy="true">
  <key column="Aid" />
  <one-to-many class="AB" />
</bag>


What can I say? Hibernate rocks.   :-)

Thomas


On 22 Feb., 21:33, Thomas Koch <[email protected]> wrote:
> Hi - I need to map a table from a legacy database to domain objects
> using NH.
>
> In this database I have a many-to-many table 'AB' with two extra
> columns on it:
>
> Table A
> Id: int
>
> Table B
> Id: int
>
> Table AB     <--- This is the many-to-many table
> Aid
> Bid
> p1: DateTime
> p2: bool
>
> Reading the documentation for NH the best bet is the composite-id tag
> but I have a hard time understanding it.
>
> Can anyone offer any practical mapping suggestions for this situation?
>
> Cheers,
> Thomas
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to