When doing a Schema Export with hbm2ddl, is there a way to specify that you DO NOT want Nullable For

Posted by Jon Erickson on Stack Overflow See other posts from Stack Overflow or by Jon Erickson
Published on 2010-03-18T23:59:24Z Indexed on 2010/03/19 0:01 UTC
Read the original article Hit count: 300

The DDL that is being created is putting all of my many to many associations into 1 table, but I actually want each many to many association in its' own table (for other reasons)

Right now hbm2ddl is creating this table (only Table1Key OR Table2Key OR Table3Key should be filled out for any given record, causing this table to have nullable foreign keys):

+-----------+
| xRef      |
+-----------+
| Table1Key |
| Table2Key |
| Table3Key |
| RiskKey   |
+-----------+

I want hbm2ddl to create the following 3 tables so that there are no nullable foreign keys.

+-----------+    +-----------+    +-----------+
| xRef1     |    | xRef2     |    | xRef3     |
+-----------+    +-----------+    +-----------+
| Table1Key |    | Table2Key |    | Table3Key |
| RiskKey   |    | RiskKey   |    | RiskKey   |
+-----------+    +-----------+    +-----------+

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about fluent-nhibernate