I'm trying to help a some friedns out and they've got something I think is BAD but wanted to bounce it off the list to make sure.
Basically, the have a java object mapped to a table "EmailSendEvent". It has many attributes but they are using two of them in a separate mapping of a persistent collection to back a <bag> mapping.
The two mappings follow at the end of this message.
They also reference the EmailSendEvent by id from other many-to-one mappings.
It seems like a bad idea to both have hibernate control the mapping for the <bag> and to have business logic depend on those objects and referencing them by id.
It seems to work, but we're tracking down bugs now that are a bit slippery.
Anyway, here are the mappings. Is this bad or am I just being overly nervous about it?
-mp
Code:
<class name="org.groundspring.emailnow.event.EmailSendEvent"
table="EventEmailSend">
<id name="id" type="long" column="id">
<generator class="native"/>
</id>
<property name="tstamp" column="tstamp" type="timestamp"
not-null="true"/>
<many-to-one name="job"
column="jobId"
class="org.groundspring.emailnow.Job"
not-null="true"/>
<many-to-one name="campaign"
column="campaignId"
class="org.groundspring.emailnow.model.Campaign"
not-null="false"/>
<many-to-one name="member"
column="memberId"
class="org.groundspring.emailnow.model.Member"
not-null="true"/>
<property name="hash" column="hash" type="long" not-null="true"/>
</class>
Code:
<bag name="sentMembers" table="EventEmailSend" lazy="true">
<key column="jobId" />
<many-to-many class="org.groundspring.emailnow.model.Member"
column="memberId"/>
</bag>