If I have something like this :
<class name="User" table="USER">
<id name="id" column="USER_ID" unsaved-value="null">
<generator class="sequence">
<param name="sequence">SEQ_USER_ID</param>
</generator>
</id>
<property name="name" column="NAME"/>
<set name="usedPasswords" table="USED_PASSWORD">
<key column="USER_ID"/>
<composite-element class="UsedPassword">
<property name="password" column="PASSWORD"/>
<property name="lastUsedDate" column="LAST_USED_DATE"/>
</composite-element>
</list>
</class>
Where the USED_PASSWORD table is something like
create table CRS_USED_PASSWORD (
USER_ID NUMBER not null,
USED_PWD_ID NUMBER not null,
PASSWORD VARCHAR2(15) not null,
LAST_USED_DATE DATE not null,
constraint PK_CRS_USED_PASSWORD primary key (USER_ID, USED_PWD_ID)
);
Or even if USED_PWD_ID were a single PK and USER_ID just an FK..
How, when I do the following...
User user = from somewhere
UsedPassword up = new UsedPassword();
// set used password details
user.getUsedPasswords.add(up);
... does the value for USED_PWD_ID get generated before the used password entity is persisted to the database.
I have a feeling I have compeletely misunderstood something here.
Many thanks
Paul Branscombe
|