| Quote: |
|
For your second point regarding composite keys, they are supported - the mapping is correct since I take it that the INVOICE_NO column is a foreign key to the INVOICES table and the the LINE_NO column is just a simple attribute that forms the rest of the pk. Correct? If this is supposed to be mapped another way please provide the details. |
| Code: |
| CREATE TABLE group (
id VARCHAR(32) NOT NULL , name VARCHAR(255) NOT NULL , PRIMARY KEY (id) ); CREATE TABLE user ( id VARCHAR(32) NOT NULL , login VARCHAR(32) NOT NULL , passwd VARCHAR(32) , PRIMARY KEY (id) ); CREATE TABLE user_group ( user_id VARCHAR(32) NOT NULL , group_id VARCHAR(32) NOT NULL , PRIMARY KEY (user_id, group_id) , CONSTRAINT FK_user_group_1 FOREIGN KEY (user_id) REFERENCES user (id) , CONSTRAINT FK_user_group_2 FOREIGN KEY (group_id) REFERENCES group (id) ); |
| Code: |
| <hibernate-mapping package="">
<class name="UserGroup" table="USER_GROUP"> <composite-id name="id" class="UserGroupKey"> <key-many-to-one name="group" column="GROUP_ID" class="Group"/> <key-many-to-one name="user" column="USER_ID" class="User"/> </composite-id> </class> </hibernate-mapping> |
| Code: |
| <composite-id name="id" class="UserGroupKey">
<key-many-to-one name="group" column="GROUP_ID" class="Group"/> <key-many-to-one name="user" column="USER_ID" class="User"/> </composite-id> |