Yes the profile is mapped as a Set.
(Partner to TransmissionProfile is an Many-to-Many relationship)
But as I don't hv access to write to the Partner table, I do not issue a
saveOrUpdate() on the Partner,
but Iterate thru the Set of TransmissionProfiles, invoking saveOrUpdate(), on each one-by-one and then commit the partnerID and profileID to the assoc table.
I guess thats why I get a delete followed by an Insert.
(I think I may not get it if I can do a save() on the Partner itself)
The console output when I invoke the storeProfile method
Code:
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: insert into TRANSMISSION_HOSTS (PORT, HOST_URL, HOST_TYPE, HOST_ID) values (?, ?, '3', ?)
Hibernate: insert into TRANSMISSION_CREDENTIALS (PASSWORD, USERNAME, HOST_ID, CREDENTIAL_ID) values (?, ?, ?, ?)
Hibernate: insert into TRANSMISSION_PROFILE (DESCRIPTION, PURPOSE, PATH, CREDENTIAL_ID, PROFILE_ID) values (?, ?, ?, ?, ?)
Hibernate: delete from OFFLINE_PARTNER_PROFILE where PARTNER_ID=?
Hibernate: insert into OFFLINE_PARTNER_PROFILE (PARTNER_ID, PROFILE_ID) values (?, ?)
The mapping files:
Code:
<hibernate-mapping>
<class name="equicom.offline.partner.Partner" table="PARTNER" dynamic-update="false" dynamic-insert="false">
<id name="id" column="PARTNER_ID" type="long">
<generator class="assigned"></generator>
</id>
<property name="code" type="string" update="false" insert="false" column="PARTNER_CD" />
<property name="isActive" type="yes_no" update="false" insert="false" column="ACTIVE_IND" />
<property name="name" type="string" update="false" insert="false" column="NAME" />
<set name="subscribedProducts" table="PARTNER_PROD" lazy="true" inverse="false" cascade="none" sort="unsorted" order-by="PROD_ID ASC" where="CHANNEL_ID=(select cc.channel_id from channel_code cc where cc.channel_cd = 'OFFLINE')">
<key column="PARTNER_ID" />
<many-to-many class="equicom.offline.partner.Product" column="PROD_ID" outer-join="false" />
</set>
<set name="offlineProfile" table="OFFLINE_PARTNER_PROFILE" lazy="true" inverse="false" cascade="none" sort="unsorted">
<key column="PARTNER_ID" />
<many-to-many class="equicom.offline.transmission_profile.TransmissionProfile" column="PROFILE_ID" outer-join="auto" />
</set>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Partner.xml
containing the additional properties and place it in your merge dir.
-->
</class>