0

In our application, we have three tables dps_user, account, and profile for building user profile. The profile table has account_id as a foreign key. Based on this design, userprofile.xml is written. account_id is mapped as an item-type in xml which is working fine for one-to-one mapping. Every single account will have a separate profile.

Now we have a scenario one-to-many mapping (One profile associated to multiple accounts). We have a new table profile_account for this which has the mappings as below.

NEW_ID   ACC_NO   PROFILE_ID
======   ======   ==========
001      001      001
001      002      001
002      001      002
002      002      002

By default Account: 001 will be mapped to Profile: 001. Post-login we will get the new_id. With this value, we will fetch accounts and user will one of the accounts in the UI.

If user selects Account: 002 with new_id, then we have to update the profile with ACC_ID: 002. To achieve this, we retrieve the account item first and then update the corresponding profile item.

When doing this, we are getting below exception often and update is failing.

Error : java.sql.SQLException: java.sql.SQLSyntaxErrorException: ORA-02049: timeout: distributed transaction waiting for lock

Sometimes the update is successful in profile table but the old account is getting deleted from account table during this update. We have the cascade as insert,update,delete for account_id in profile table.

userProfile.xml:
<item-descriptor name="user" item-cache-size="3000" item-cache-timeout="900000" query-cache-size="1000" query-expire-timeout="900000">
    <table name="PROFILE" type="auxiliary" id-column-name="user_id">
        <property name="account" display-name="Account" column-name="ACCOUNT_ID" item-type="account" cascade="insert,update,delete" />
    </table>
</item-descriptor>
<item-descriptor name="account">
    <table name="ACCOUNT" type="primary" id-column-names="ID">
    <property name="accountNo" data-type="string" column-name="ACC_NO" />
    </table>
</item-descriptor>
Vijay
  • 19
  • 1
  • 5
  • Please post the parts of your `userprofile.xml` that represent the design you describe above. Will help in understanding your problem. – radimpe Oct 25 '16 at 15:27
  • @radimpe: I have added userProfile.xml code. Pls check. – Vijay Oct 27 '16 at 05:25
  • Where do you use the new table `profile_account`? – radimpe Oct 27 '16 at 10:10
  • profile_account has not been linked with user item descriptor. We have a separate item descriptor for this. We just make a query to profile_account to get the profile id to update the account_id in profile table. – Vijay Oct 27 '16 at 11:20
  • The issue you are seeing is probably related to the referential constraints in the database. Oracle support has a [document](https://support.oracle.com/epmos/faces/DocumentDisplay?id=1493327.1) which describes the fix for this. – bated Nov 03 '16 at 18:43

0 Answers0