[redhat-ccm-list] Aplaws 5.2 Pdl problem

David Young David.Young at southoxon.gov.uk
Mon Jul 19 10:04:11 UTC 2004


That seems to work.

Thanks muchly.

David

>>> Matthew Booth <mbooth at redhat.com> 16/07/2004 16:59:42 >>>
On Fri, 2004-07-16 at 16:12, David Young wrote:
> Hi,
> 
> I'm using Aplaws 5.2, and I am developing the following pdl for
> attaching data to a User Object.  I have used the UserAuthentication
pdl
> as a template for this pdl.
> 
> 
> ###################################
> 
> object type NotificationUserProfile {
> 
>    BigDecimal id = notification_user_profiles.profile_id INTEGER;
> 
>    unique String [0..1] mobilePhoneNumber =
> notification_user_profiles.mobile_phone_number VARCHAR(50);
> 
>   // ... other stuff cut out
> 
>    User [1..1] user = join notification_user_profiles.user_id to
> users.user_id;
> 
>    object key (id);
>    join notification_user_profiles.profile_id to parties.party_id;
> 
>    // Avoid deletion of parties with the profile
>    delete {
>       do {
>          delete from notification_user_profiles where profile_id =
:id
>       }
>    }
> 
>    insert {
>       do {
>          insert into notification_user_profiles
>          (profile_id, email_varified, mobile_varified,
>           event_sms, event_email, news_sms, news_email,
>           meetings_sms, meetings_email,
>           mobile_phone_number, user_id)
>          values
>          (:id, :emailVarified, :mobileVarified,
>           'N', 'N', 'N', 'N', 'N', 'N',
>           :mobilePhoneNumber, :user.id)
>       }
>    }
> 
>    update {
>       do {
>          update notification_user_profiles
>          set email_varified = :emailVarified,
>              mobile_varified = :mobileVarified,
>              event_sms = :eventSMS,
>              event_email = :eventEmail,
>              news_sms = :newsSMS,
>              news_email = :newsEmail,
>              meetings_sms = :meetingsSMS,
>              meetings_email = :meetingsEmail,
>              mobile_phone_number = :mobilePhoneNumber,
>              user_id = :user.id
>          where id = :id
>       }
>    }
> 
>    add user {}
>    remove user {}
> 
> }
> 
> ################################################
> 
> 
> This seems to work fine up until you try to delete a user using the
> standard admin tools.  Deleting the user violates a foreign key type
> constraint on the notification_user_profiles table and therefore
fails.
> 
> I'm unsure how I go about changing the behaviour so that the delete
> operation on the user cascades to the profile.
> 
> I can't work out why this fails for this profile, but is successful
for
> the UserAuthentication.

In general, there's no need any more to explicitly enter sql for all
your events. Persistence will just generate them.

Try something like this:

object type NotificationUserProfile {

   BigDecimal id = notification_user_profiles.profile_id INTEGER;

   unique String [0..1] mobilePhoneNumber =
notification_user_profiles.mobile_phone_number VARCHAR(50);

  // ... other stuff cut out

   object key (id);
}

association {
    composite User[1..1] user = join
notification_user_profiles.user_id
to users.user_id;
    component NotificationUserProfile[0..1] notificationUserProfile =
join users.user_id to notification_user_profiles.user_id;
}

Notice I've made User composite and NotificationUserProfile component.
This says that the profile is a component of the user, and should be
deleted with the user.

NB: this works fine on 6.1, and is supposed to work fine on 5.2. If it
doesn't, you may have to play with it a bit :)

Matt

-- 
Redhat-ccm-list mailing list
Redhat-ccm-list at redhat.com 
https://www.redhat.com/mailman/listinfo/redhat-ccm-list 
Archives: https://www.redhat.com/pipermail/redhat-ccm-list/







**********************************************************************
The information contained in this transmission may be
confidential and may also be the subject of legal
professional privilege. If you are not the intended recipient,
any use, disclosure or copying of any part of this transmission
is unauthorised. If you have received this transmission in
error, please notify the originator immediately.

www.southoxon.gov.uk
**********************************************************************





More information about the Redhat-ccm-list mailing list