I have a rather simple question. I was reading through the hibernate tips and tricks faq and came to the following question.
I have a many-to-many association between two tables, but the association table has some extra columns (apart from the foreign keys). What kind of mapping should I use? Use a composite-element to model the association table. For example, given the following association table:
create table relationship ( fk_of_foo bigint not null, fk_of_bar bigint not null, multiplicity smallint, created date )
you could use this collection mapping (inside the mapping for class Foo)
<set name="relationship"> <key column="fk_of_foo"/> <composite-element class="Relationship"> <property name="multiplicity" type="short"/> <property name="created" type="date"/> <many-to-one name="bar" class="Bar"/> </composite-element> </set>
I also noticed the following in the hibernate manual: "Please note that a composite element mapping doesn't support null-able properties if you're using a <set>."
So my question is, in the above mapping from the faq, are the properties 'multiplicity' and 'created' allowed to be null? More precisely put, is the mapping from the faq correct since the ddl for the table will allow null values?
Thanks,
Mike
|