I understand about the tone of my message, but you are the only person who has responed to this messeage since I posted it in Early May. So I guess the frustration is just building. Sorry.
I do try to help other when i can, but find myself stuck on a few items here.


In my AlertDto, I have these 2 methods:

  public void setRemovedContacts(Collection removedContacts)
  {
     this.removedContacts.clear();
     this.removedContacts.addAll(removedContacts);
  }

  public void clearContacts()
  {
          this.Contacts.clear();
  }


I am just looking now for which ones I am using as I have started other things while waiting for responses.




---
Thanks...
Mick Knutson
---





From: "Harkness, David" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: <[EMAIL PROTECTED]>
Subject: RE: [Xdoclet-user] updating a m-m value object?
Date: Sat, 28 Jun 2003 15:39:55 -0700

Mick,

I'm not using Vos nor modeled M:N relationships (I need attributes on
the joining table), but I took a look at the generated VO code (it's
still in there, I'm just not using it). It seems pretty clear that what
your doing will not work without modifying the generated VO-code (the
template, really).

Here's what happens when you remove a Phone from a User (User is 1:N to
Phone):

   public void removePhones(dd.ejb.entity.identity.PhoneVO removed)
   {
          this.Phoness.remove(removed);
          this.removedPhoness.add(removed);
          if (this.addedPhoness.contains(removed))
                 this.addedPhoness.remove(removed);
          if (this.updatedPhoness.contains(removed))
                 this.updatedPhoness.remove(removed);
   }

Ignore the fact that Phones are called Phoness (I named the aggregate
Phones as the example code uses plural too). It stores a reference in
the "to-be-removed" collection. However, here's the code for clearing
the list of Phones:

   public void clearPhoness()
   {
          this.Phoness.clear();
   }

As you can see, it just "forgets" the loaded phones. It doesn't put them
into the "to-be-removed" collection to be used by the bean. This should
loop through the phones and call removePhone() for each. I suggest you
look at the generated VO code for you M:N relationship and see if it's
doing something similar.

On a personal note, please remember that this is not a support forum. I
do not work on Xdoclet (though I'd like to find some small piece to help
out with) -- I'm a user like you. I help others out when I can for many
reasons: it improves my knowledge, it's good karma, and finally, I'm
just a nice guy. :) It doesn't inspire me to help when I read, "is there
just no person ... willing to help?" I guess my only suggestion would be
to try to investigate the issue further if you get no response rather
than reposting the same query with no additional information again and
again. </soapbox>

Good luck!

David Harkness
Sony Pictures Digital Networks

P.S. Was my reply about your 1:1 relationship issue helpful? Did you get
anywhere with it?

-----Original Message-----
From: Mick Knutson [mailto:[EMAIL PROTECTED]
Sent: Saturday, June 28, 2003 8:20 AM
To: [EMAIL PROTECTED]
Subject: Re: [Xdoclet-user] updating a m-m value object?


Am I the only person trying to delete the 'n' side of m-n relationships? or is there just no person in the past 3 weeks of my asking willing to help me fix this issue? Can someone please help?


I can't seem to figure out how to delete the m-n relationships. I can create them just fine, but when I try to call clear() on my VO, the values do not sem to get cleared, and they are not deleted from the relation table.


--- Thanks... Mick Knutson ---





>From: "Mick Knutson" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: [Xdoclet-user] updating a m-m value object?
>Date: Tue, 03 Jun 2003 20:06:04 -0700
>
>I have made some progress, but not enough to have my application work.
>I now have Contacts in my DB. And I have 3 different Alert's already
>there as well. When there are no mapped relashionships in my DB, all 3
>Alerts show zero Contacts Selected.
>But, in various combinations, it seems that a given Contact can only be

>mapped to 1 Alert at a time. This is far from what I need as I need
TRUE
>M-M mapping.
>
>Can anyone please tell me why this is happening and how I can fix this?
>
>---
>Thanks...
>Mick Knutson
>---
>
>
>OK, This is my second post as nobody responded to me the first time. I
>am seriously trying to figure this out but no luck. I added the code I
>have below, but my M-M relationship is not updating correctly, or
>consistantly. It just seems to randomly update the fields it wants, but

>only 1 Alert at a time. So modifying multiple alerts does not actually
>take. Can someone please help me?
>
>
>
>Struts Action add:
>==================
>    public ActionForward add( ActionMapping mapping
>                              , ActionForm form
>                              , HttpServletRequest request
>                              , HttpServletResponse response
>                              )
>    throws Exception
>    {
>        try
>        {
>            if( log.isInfoEnabled() )
>            {
>                log.info( "Process a alert add(...)" );
>                log.info( "alertForm::add(): " + form.toString() );
>            }
>
>            IAlertServices asd = this.getAlertService();
>
>            UserLightDto userlightDto = getUserContainer( request
>).getUserLightDto();
>
>            AlertDto alertDto = new AlertDto();
>            BeanUtils.copyProperties( alertDto, form );
>
>            if( log.isInfoEnabled() )
>            {
>                log.info( "alertUpdate.dto: " + alertDto.toString() );
>            }
>
>            // First we need to create the ContactDto objects from our
>String[]
>            String[] alertContacts = (String[])( (DynaActionForm) form
>).get( Constants.ALERT_CONTACTS_KEY );
>
>            if( alertDto.getAlertId().equals( "" ) )
>            {
>                // Must be a new alert then....add it
>                log.info( "Must be a new alert then....Add it" );
>
>                // We first have to create the alert. Then, only after
>creation, can we add the contacts.
>                alertDto = asd.alertCreate( alertDto );
>
>                log.info( "String[] alertContacts length: " +
>alertContacts.length );
>                alertDto = setAlertContactsFromForm( alertDto,
>alertContacts );
>                alertDto = asd.alertUpdate( alertDto );
>                return ( mapping.findForward( Constants.SUCCESS_FWD )
);
>            }
>
>            log.info( "Must be an existing alert then....update it" );
>            alertDto.clearContacts();
>            alertDto = asd.alertUpdate( alertDto );
>            alertDto = setAlertContactsFromForm( alertDto,
alertContacts );
>            alertDto = asd.alertUpdate( alertDto );
>
>            // Forward control to the specified success URI
>            return ( mapping.findForward( Constants.SUCCESS_FWD ) );
>        }
>        catch( Exception e )
>        {
>            log.error( "Exception adding alert; " + e.getMessage(), e
);
>            throw e;
>        }
>    }
>
>
>    private String[] setAlertContactsToForm( AlertDto alertDto )
>    {
>        //
>        ContactDto[] alertContacts = alertDto.getContacts();
>        String[] contacts = new String[alertContacts.length];
>
>        for( int i=0; i < alertContacts.length; i++ )
>        {
>            log.info( "alertContacts[i]: " +
alertContacts[i].toString() );
>            contacts[i] = alertContacts[i].getContactId();
>        }
>        return contacts;
>    }
>
>    private AlertDto setAlertContactsFromForm( AlertDto alertDto,
>String[]
>contacts )
>    {
>        alertDto.clearContacts();
>
>        for( int i=0; i < contacts.length; i++ )
>        {
>            ContactDto contact = new ContactDto();
>            log.info( "contacts[i]: " + contacts[i] );
>            contact.setContactId( contacts[i] );
>            alertDto.addContact( contact );
>        }
>        return alertDto;
>    }
>
>
>AlertManager:
>==============
>    public AlertDto alertUpdate( AlertDto alertData )
>    throws EJBException
>    {
>        try
>        {
>            AlertLocalHome alertLocalHome = AlertUtil.getLocalHome();
>
>            if( log.isInfoEnabled() )
>            {
>                log.info( "Update alert Data with this: " +
>alertData.toString() );
>            }
>
>            AlertLocal alert = null;
>            Long alertSequence = null;
>
>            try
>            {
>                alert = alertLocalHome.findByPrimaryKey(
>alertData.getAlertId() );
>            }
>            catch(Exception e)
>            {
>                if( log.isInfoEnabled() )
>                {
>                    log.info( "No alert found. So create a new alert
row
>and populate it with this data." );
>                }
>
>                // create a profile then...
>                alertData.setAlertId( AlertUtil.generateGUID( alertData

>)
>);
>                alert = alertLocalHome.create( alertData );
>                return alert.getAlertDto();
>            }
>
>            log.info( "Update alertDto data: " + alertData.toString()
);
>            alert.setAlertDto( alertData );
>
>            AlertDto dto = alert.getAlertDto();
>
>            if (log.isInfoEnabled())
>            {
>                log.info( "alertUpdate.dto: " + dto.toString() );
>            }
>
>            return dto;
>        }
>        catch(Exception e)
>        {
>            log.error( "Error performing Alert update.", e);
>            throw new EJBException( e.getMessage() );
>        }
>    }
>
>
>Alert Entity:
>=============
>package com.baselogic.yoursos.alert;
>
>import java.util.Collection;
>import java.util.Date;
>
>//import com.baselogic.yoursos.contact.ContactLocal;
>import com.baselogic.yoursos.contact.ContactDto;
>
>/**
>* The Entity bean represents a Alert Entity
>*
>* @author Mick Knutson
>* @version $Revision: 1.1 $
>*
>* @ejb.bean
>*       name="Alert"
>*       display-name="Alert for YourSos"
>*       cmp-version="2.x"
>*       type="CMP"
>*       view-type="local"
>*       local-jndi-name="local/com.baselogic.yoursos.alert.AlertLocal"
>*       primkey-field="alertId"
>*       schema="Alert"
>*
>* @ejb.pk
>*       class="java.lang.String"
>*
>* @ejb.value-object
>*       match="*"
>*       name="Alert"
>*
>* @ejb.finder   signature="java.util.Collection findAllByUserId(
>java.lang.Long pUserId )"
>*               query="SELECT OBJECT(c) FROM Alert AS c WHERE c.userId
=
>?1"
>* @jboss.query  signature="java.util.Collection findAllByUserId(
>java.lang.Long pUserId )"
>*               query="SELECT OBJECT(c) FROM Alert AS c WHERE c.userId
=
>?1"
>*
>* @ejb.util
>*       generate="physical"
>*
>* @ejb.transaction
>*       type="Required"
>*
>* @ejb.transaction-type
>*       type="Container"
>*
>* @ejb.permission
>*       unchecked="true"
>*
>* @jboss.table-name
>*       table-name="alert"
>*
>* @jboss.create-table
>*       create="false"
>*
>* @jboss.remove-table
>*       remove="false"
>*
>**/
>public abstract class AlertBean implements javax.ejb.EntityBean
>{
>    private javax.ejb.EntityContext myEntityCtx;
>
>    //
>-----------------------------------------------------------------------
--
>    // Properties (Getters/Setters)
>    //
>-----------------------------------------------------------------------
--
>
>    /**
>    * Retrieve the Alert's sequenceName for use as a primaryKey.
>    *
>    * @ejb.pk-field
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="alert_id"
>    **/
>    public abstract java.lang.String getAlertId();
>
>    /**
>    * No interface method for setAlertId(..). See page 130 of the EJB
>2.0
>specification:
>    * "Once the primary key for an entity bean has been set, the Bean
>Provider must
>    * not attempt to change it by use of set accessor methods on the
>primary key
>    * cmp-fields. The Bean provider should therefore not expose the set

>accessor
>    * methods for the primary key cmp-fields in the component interface
of
>the
>    * entity bean.". A work around would be to remove and then an
re-create
>the bean.
>    */
>    public abstract void setAlertId( java.lang.String pAlertId );
>
>    /**
>    * Manage the Allergies's userId FK.
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss:column-name name="user_id_fk"
>    **/
>    public abstract Long getUserId();
>    public abstract void setUserId( Long pUserId );
>
>    /**
>    * Manage the Alert's subject.
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="subject"
>    *
>    **/
>    public abstract String getSubject();
>    public abstract void setSubject( String pSubject );
>
>    /**
>    * Manage the Alert's StartDate
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="starting_date"
>    *
>    **/
>    public abstract java.util.Date getStartDate();
>    public abstract void setStartDate( java.util.Date pStartDate );
>
>    /**
>    * Manage the Alert's Reoccurring
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="reoccurring"
>    **/
>    public abstract String getReoccurring();
>    public abstract void setReoccurring( String pReoccurring );
>
>    /**
>    * Manage the Alert's GracePeriodDays
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="grace_period_days"
>    *
>    **/
>    public abstract String getGracePeriodDays();
>    public abstract void setGracePeriodDays( String pGracePeriodDays
);
>
>    /**
>    * Manage the Alert's GracePeriodHours
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="grace_period_hours"
>    *
>    **/
>    public abstract String getGracePeriodHours();
>    public abstract void setGracePeriodHours( String
pGracePeriodHours );
>
>    /**
>    * Manage the Alert's EndingDate
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="ending_date"
>    *
>    **/
>    public abstract java.util.Date getEndingDate();
>    public abstract void setEndingDate( java.util.Date pEndingDate
);
>
>    /**
>    * Manage the Alert's StartingLocation
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="starting_location"
>    *
>    **/
>    public abstract String getStartingLocation();
>    public abstract void setStartingLocation( String
pStartingLocation );
>
>    /**
>    * Manage the Alert's EndingLocation
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="ending_location"
>    *
>    **/
>    public abstract String getEndingLocation();
>    public abstract void setEndingLocation( String pEndingLocation
);
>
>    /**
>    * Manage the Alert's Status
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="status"
>    *
>    **/
>    public abstract String getStatus();
>    public abstract void setStatus( String pStatus );
>
>    /**
>    * Manage the Alert's SafeConfirm
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="safe_confirm"
>    *
>    **/
>    public abstract String getSafeConfirm();
>    public abstract void setSafeConfirm( String pSafeConfirm );
>
>    /**
>    * Manage the Alert's Details
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="details"
>    *
>    **/
>    public abstract String getDetails();
>    public abstract void setDetails( String pDetails );
>
>    /**
>    * Manage the Alert's NoteToContactees
>    *
>    * @ejb.persistent-field
>    * @ejb.interface-method
>    * @jboss.column-name name="note_to_contactees"
>    *
>    **/
>    public abstract String getNoteToContactees();
>    public abstract void setNoteToContactees( String
pNoteToContactees );
>
>
>
>
>
>
>    /**
>    * Manage the Alert's DTO/Form object
>    *
>    * @ejb.interface-method
>    * @ejb.transaction
>    *       type="Supports"
>    **/
>    public abstract AlertDto getAlertDto();
>
>    /**
>    * Manage the Alert's DTO/Form object
>    *
>    * @ejb.interface-method
>    * @ejb.transaction
>    *       type="Supports"
>    **/
>    public abstract void setAlertDto( AlertDto pAlertDto );
>
>
>
>    /**
>     * 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();
>
>
>    /**
>     * Get all Location's for this alert.
>     *
>     * @ejb.interface-method
>     *
>     * @ejb.relation
>     *       name="Alert-Location"
>     *       role-name="alerts-have-many-locations"
>     *       target-ejb="Location"
>     *       target-role-name="locations-belong_to-many-alerts"
>     *       target-multiple="yes"
>     *
>     * @ejb.relation-table
>     *       table-name="alert_location_rel"
>     *       create-table="false"
>     *       remove-table="false"
>     *
>     * @jboss.relation
>     *       related-pk-field="locationId"
>     *       fk-column="location_id"
>     *       fk-constraint="false"
>     *
>     * @jboss.relation-mapping
>     *       style="relation-table"
>     *
>     * @ejb.value-object
>     *       aggregate="com.baselogic.yoursos.location.LocationDto"
>     *       aggregate-name="Location"
>     *       match="normal"
>     *       members="com.baselogic.yoursos.location.LocationLocal"
>     *       members-name="Location"
>     *       type="Collection"
>     *       relation="external"
>     *
>     */
>    public abstract Collection getLocations();
>    public abstract void setLocations();
>
>
>
>
>
>    //
>-----------------------------------------------------------------------
--
>    // Framework Callbacks
>    //
>-----------------------------------------------------------------------
--
>    /**
>    * Create a TestEntity based on the supplied TestEntity Value
Object.
>    *
>    * @param pAlertDto The name used to create the Alert.
>    *
>    * @throws javax.ejb.EJBException If no new unique ID could be
retrieved
>this will
>    *                      rollback the transaction because there is no
>    *                      hope to try again
>    * @throws javax.ejb.CreateException Because we have to do so (EJB
>spec.)
>    *
>    * @ejb.interface-method view-type="local"
>    * @ejb.create-method view-type="local"
>    **/
>    public java.lang.String ejbCreate( AlertDto pAlertDto )
>    throws javax.ejb.EJBException, javax.ejb.CreateException
>    {
>        setAlertId( pAlertDto.getAlertId() );
>        setAlertDto( pAlertDto );
>
>        return null;
>    }
>
>    /**
>    * String Value of this Alert Entity
>    *
>    * @ejb.interface-method
>    *
>    **/
>    public String toString()
>    {
>        try
>        {
>                return( getAlertDto().toString() );
>        }
>        catch(Exception e){return "";}
>    }
>
>
>    //
>-----------------------------------------------------------------------
--
>    // EJB Callbacks
>    //
>-----------------------------------------------------------------------
--
>    public void ejbPostCreate( AlertDto pAlertDto )
>    {/* Do nothing yet */}
>
>    public void setEntityContext( javax.ejb.EntityContext lContext )
>    {
>        myEntityCtx = lContext;
>    }
>
>    public void unsetEntityContext()
>    {
>        myEntityCtx = null;
>    }
>
>    public void ejbActivate()
>    {}
>
>    public void ejbPassivate()
>    {}
>
>    public void ejbLoad()
>    {}
>
>    public void ejbStore()
>    {}
>
>    public void ejbRemove()
>    throws javax.ejb.RemoveException
>    {}
>
>} //The End...
>
>
>Contact Entity:
>==================
>    /**
>    * 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( AlertLocal pAlert );
>
>_________________________________________________________________
>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

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user


------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01 _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to