Hi,
I'm trying to implement the pattern discussed in section 23.3 of the online Hibernate manual. This is (supposedly) a many:many association with an augmented association table. In the example it's Customer x Product, with "Order" the association table. The resulting .hbm.xml file is
<class name="Customer" table="customers"> ... <set name="orders" inverse="true"> <key column="customer_id"/> <one-to-many class="Order"/> </set> </class>
<class name="Order" table="orders"> ... <many-to-one name="customer" column="customer_id"/> <list name="lineItems" table="line_items"> <key column="order_id"/> <list-index column="line_number"/> <composite-element class="LineItem"> <!-- definition of "LineItem" class --> <property name="quantity"/> ... <many-to-one name="product" column="product_id"/> </composite-element> </list> </class>
<class name="Product" table="products">...</class>
I can get most of it with XDoclet, but am stymied with the contents of the composite-element tag. The "LineItem" tags produce a standalone .hbm.xml file, not a nested definition.
I considered using a merge file for this stanza, but my analogues to Order and LineItem are sufficiently complex that I would really hate to be forced to maintain them manually.
Other possibilities are using a one-to-one association or joined-subclass with a separate LineItem class. I haven't explored these in detail since they wouldn't fix the problem of manually maintaining 'Order.' (I'm also not sure they would actually solve the problem of the nested 'LineItem' configuration either.)
I've never done this before, but thought I'd ask: have you tried using the @hibernate.collection-composite-element tag?
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ xdoclet-user mailing list xdoclet-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-user