I have gotten most of this to work. I have 1, hopefully simple issue to resolve with this:
I can add relationships just fine now. But lets say I have 3 different Contacts that are associated to this 1 Alert. Then I decide to remove 1 of those contacts in the multiple select box. I need that 1 Contact removed from the relation table.
Currently, I can't seem to remove it.
Here is what I do when I get an modification to an Alert:
===========================================
alertDto.clearContacts();
alertDto = asd.alertUpdate( alertDto ); for( int i=0; i < alertContacts.length; i++ )
{
// Get the required ContactDto...
ContactDto contactDto = usd.findContact( alertContacts[i] );
log.info( "contactDto[i]: " + contactDto.toString() );
alertDto.addContact( contactDto );
}alertDto = asd.alertUpdate( alertDto );
Now, I am using Struts, so the Contacts come to me as "String[] contactId" and then I have to get the DTO/VO from that.
What am I missing to have the removed relationships be removed if they are not in the "String[] contactId" anymore?
--- Thanks... Mick Knutson ---
From: Jason Essington <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: AW: [Xdoclet-user] updating a m-m value object? Date: Fri, 6 Jun 2003 11:24:46 -0600
So, two things AlertBean: ========= /** * Get all Contact's for this alert. * * @ejb.interface-method * * @ejb.relation * name="Alert-Contact" * role-name="alerts-have-many-contacts"
this is a bi-directional relationship, so leave out the target stuff, xdoclet will figure it out on its own
* * @ejb.relation-table * table-name="alert_contacts_rel" * create-table="false" * remove-table="false" * * @jboss.relation * related-pk-field="contactId" * fk-column="contact_id" * fk-constraint="false" * * @jboss.relation-mapping * style="relation-table" * * @ejb.value-object * aggregate="com.baselogic.yoursos.contact.ContactDto" * aggregate-name="Contact" * match="normal" * members="com.baselogic.yoursos.contact.ContactLocal" * members-name="Contact" * type="Collection" * relation="external" */ public abstract Collection getContacts(); public abstract void setContacts( Collection pContacts );
ContactBean: =========== /** * Get the User for this Contact * * @ejb.interface-method * * @ejb.relation * name="Alert-Contact" * role-name="contact-belongs_to-many-alerts"
other side of the relationship, no target-xxx properties should be here either.
* * @ejb.relation-table * table-name="alert_contacts_rel" * create-table="false" * remove-table="false" * * @jboss.relation * related-pk-field="alertId" * fk-column="alert_id" * fk-constraint="false" * * @jboss.relation-mapping * style="relation-table" **/
this getter should be a Collection too
public abstract Collection getAlert(); public abstract void setAlert( Collection pAlerts );
-jason
On Friday, June 6, 2003, at 05:41 AM, Mick Knutson wrote:
I made sure the changes where what you mentioned. The randomness seems to be gone, but each Contact can only be associated with one (1) Alert still.
Here is the relevant code as per your email:
AlertBean: ========= /** * Get all Contact's for this alert. * * @ejb.interface-method * * @ejb.relation * name="Alert-Contact" * role-name="alerts-have-many-contacts" * target-ejb="Contact" * target-role-name="contact-belongs_to-many-alerts" * --target-multiple="yes" * * @ejb.relation-table * table-name="alert_contacts_rel" * create-table="false" * remove-table="false" * * @jboss.relation * related-pk-field="contactId" * fk-column="contact_id" * fk-constraint="false" * * @jboss.relation-mapping * style="relation-table" * * @ejb.value-object * aggregate="com.baselogic.yoursos.contact.ContactDto" * aggregate-name="Contact" * match="normal" * members="com.baselogic.yoursos.contact.ContactLocal" * members-name="Contact" * type="Collection" * relation="external" */ public abstract Collection getContacts(); public abstract void setContacts( Collection pContacts );
ContactBean: =========== /** * Get the User for this Contact * * @ejb.interface-method * * @ejb.relation * name="Alert-Contact" * role-name="contact-belongs_to-many-alerts" * target-ejb="Alert" * target-role-name="alerts-have-many-contacts" * --target-multiple="yes" * * @ejb.relation-table * table-name="alert_contacts_rel" * create-table="false" * remove-table="false" * * @jboss.relation * related-pk-field="alertId" * fk-column="alert_id" * fk-constraint="false" * * @jboss.relation-mapping * style="relation-table" **/ public abstract AlertLocal getAlert(); public abstract void setAlert( Collection pAlerts );
Thanks in advance for your help....
------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The best thread debugger on the planet. Designed with thread debugging features you've never dreamed of, try TotalView 6 free at www.etnus.com. _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-userimp
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail
------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The best thread debugger on the planet. Designed with thread debugging features you've never dreamed of, try TotalView 6 free at www.etnus.com. _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
