Unique Key Violation While Doing Multiple Updates And Create in EJB

Hello All,
I am using oracle 9i and Weblogic 7.0. I have a table that has a unique key constraint on one column , say 'Col1' and i am using a CMP to read,create and update data in this table. The problem description is as follows.
I have JTable that display the data from the above said table. The user can modify the existing data and insert new data that will be reflected in the DB using the CMP. Let us say the following are displayed
ROW1
Col1 : 3
Col2 : 'ABC'
Col3 : 1 (Primary key in the table)
Now the user modifies the above row and inserts a new record. Now the following will be the display
ROW1 (Modified)
Col1 : 4
Col2 : 'ABC'
Col3 : 1 (Primary key in the table)
ROW2 (New)
Col1 : 3
Col2 : 'DEF'
Col3 : 2 (Primary key in the table)
When the above data is saved i do the following in the Code
a) Session Bean
For (all the data in the Jtable)
try
home.findByPrimaryKey(Col3);
remote.update(Col1,Col2);
catch(FinderException fe)
home.create(Col1,Col2,Col3);
When the above code is run During the first loop the update runs succesfully (i.e update old value of 3 with 4 ) but during the 2nd loop the create (i.e Insert new value 3) gives me the unique key violated exception. The following is the stack trace
<Oct 25, 2004 11:36:22 AM IST> <Info> <EJB> <010049> <EJB Exception in method: ejbPostCreate: java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:579)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1892)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2130)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2013)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2869)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
at weblogic.jdbc.jts.Statement.executeUpdate(Statement.java:509)
at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.__WL_create(TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.java:1435)
at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.ejbPostCreate(TerminalPaymentsCMP_kbdoop__WebLogic_CMP_RDBMS.java:1353)
at java.lang.reflect.Method.invoke(Native Method)
at weblogic.ejb20.manager.DBManager.create(DBManager.java:1023)
at weblogic.ejb20.manager.DBManager.localCreate(DBManager.java:904)
at weblogic.ejb20.internal.EntityEJBLocalHome.create(EntityEJBLocalHome.java:180)
at de.dl.ucs.contract.entity.TerminalPaymentsCMP_kbdoop_LocalHomeImpl.create(TerminalPaymentsCMP_kbdoop_LocalHomeImpl.java:73)
at de.dl.ucs.contract.helperclasses.SubsegmentMaintanence.saveTerminalPayments(SubsegmentMaintanence.java:697)
at de.dl.ucs.contract.controller.SubsegmentSL.saveSubsegmentDetails(SubsegmentSL.java:570)
at de.dl.ucs.contract.controller.SubsegmentSL.processFinanceSubsegmentSave(SubsegmentSL.java:1601)
at de.dl.ucs.contract.controller.SubsegmentSL_kgzv4j_EOImpl.processFinanceSubsegmentSave(SubsegmentSL_kgzv4j_EOImpl.java:498)
at de.dl.ucs.contract.events.FinanceSubsegmentBEH.saveSubsegmentDetails(FinanceSubsegmentBEH.java:749)
at de.dl.ucs.contract.events.FinanceSubsegmentBEH.processEvent(FinanceSubsegmentBEH.java:232)
at de.dl.ucs.framework.flowcontroller.ControllerBean.delegateAction(ControllerBean.java:229)
at de.dl.ucs.framework.flowcontroller.ControllerBean_riqvk4_EOImpl.delegateAction(ControllerBean_riqvk4_EOImpl.java:46)
at de.dl.ucs.framework.flowcontroller.ControllerBean_riqvk4_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:441)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:382)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:726)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:377)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:234)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:210)
>
<Oct 25, 2004 11:36:22 AM IST> <Info> <EJB> <010051> <EJB Exception during invocation from home: [email protected] threw exception: javax.ejb.TransactionRolledbackLocalException: EJB Exception:; nested exception is: java.sql.SQLException: ORA-00001: unique constraint (UAT_CYCLE2_1.UK_PYMT_DET_TX) violated
Please help me with this, as far as i am concerned since both update and create is in the same transaction the update on the row must be visible to the create and hence there shouild not be any problem.....
thanks in advance
Shanki

Hi,
Thanks,
There are 3 columns involved with that table . Out of whihc one is a Primary Key (string) , The other column (Number) has a unique key constraint defined on it and the last column stores a value corresponding to the 2nd column.
The reason for me to do a create in the Finder exception is as follows.
I Loop through the Data present in JTable. As given in the example let us assume that there are 2 rows in the JTable. Out of whihc the First row needs an updation and the second row , which is a new row needs to be created. So During the First iteration of the loop, The findermethod does not throw any exception (Because it is a modfied row) and hence the update gets fired successfully. During the second iteration , since it is a new row the findermethod will throw a finder exception and hence create will get fired.
I understand that this is not a good coding style but then it is not 100% wrong and i need to find out as to why it is not working.
Hope am clear in explaining my problem
Thanks
Shanki

Similar Messages

  • How to handle multiple updates and creates sequentially

    Hi All,
    I have a requirement where multiple updates and creates will happen on an Order (say Purchase Order). I need to capture all these updates/creates and synchronize the other system in real time. In other words, as soon an order is updated/created in EBS, the same needs to be reflected in other system database.
    I have thought of using a JMS queue that'll store all the incoming creates/updates and a BPEL process will keep polling this queue. But in this case how do I ensure the sequence in which the new instances will be created. e.g. create order message was picked first from the queue and an instance got created. While this instance was in execution, another update happened on the same order for which another instance got created. Now before the first instance could get completed and created an order, second instance is trying to update the custom database because of which it would fail. How to restrict second instance from running before the completion of the first one?
    I have also thought of capturing Order Update/Create business events from EBS but there also the same problem. Instance created by Update event can try to do the update before the instance created by Order Create could create a new order.
    Any method to solve this.
    Any pointers/suggestions/approaches are more than welcome.
    SOA Suite 11.1.1.3
    Regards,
    Neeraj Sehgal

    maybe unit of order and unit of work can help you on that, though i haven't any experience on both topics :
    http://download.oracle.com/docs/cd/E12840_01/wls/docs103/jms/uow.html
    http://download.oracle.com/docs/cd/E12840_01/wls/docs103/jms/uoo.html
    or the mediator supports some sort of sequencer, see : http://www.xenta.nl/blog/2010/05/14/oracle-soa-suite-11g-resequence-messages-in-mediator/

  • HT4623 While doing the update and restoring for IOS 6 on Iphone 4s an error appear it says- The iphone cannot be restored. An unknown error occurred ''3002''. I need help !!

    I need help what could i do to solve this error -problem?

    Hi EddyM96,
    Welcome to Apple Support Communities.
    You may find the steps in this article helpful for troubleshooting your iPhone:
    iOS: Unable to update or restore
    http://support.apple.com/kb/ht1808
    Best,
    Jeremy

  • Unique key violation i.e. primary key violation in JSF page

    Hi, I am using Jdeveloper 11.1.1.5.0 and working with adf fusion web application. I have created entity object and view object. In view object I have primary key and I have set it's type to DB sequence. THe problem is though the attribute is DB sequence. IN JSF page it show unique key violation i.e. primary key violation. Please help me

    So, do you have a trigger in the database that updates the value of the primary key? Or do you assign the value in some other way?
    You can check [url http://download.oracle.com/docs/cd/E16162_01/web.1112/e16182/toc.htm]the docs for information about the ways it can be done.

  • HT4623 i disconnected my iphone 4 while it was updating and now its frozen, the screen is showing a apple logo and a loading bar which has been for 9hrs now. please help

    i disconnected my iphone 4 while it was updating and now its frozen, the screen is showing a apple logo and a loading bar which has been for 9hrs now. please help

    It's not uncommon for it to not work the first time and sometimes, you have to try it a few times. Turn off your antivirus software and your firewall while you are trying to restore the iPad. Enable them again after you restore.
    If that still won't work, post back with detailed information as to what exactly does happen as you go through the process.

  • Blackberry Z10 Limited Edition bricked while doing OTA update

    Hi Guys,
    I need your help to restore my Z10 LE.
    It is bricked while doing OTA update. Currently, it stuck in installing process.
    After doing restart, it will install the updates and when reaching 100%, it stuck there.
    I've tried to reinstall using web updater and BB Link. But, no result. Both method report that there is no update available for my BB. I guess, they think my BB already updated.
    I trying to install using sachesi. However, I'm not sure what parameter should I use to find the perfect ROM.
    Can you guys help me fill the parameter? or... maybe there is a direct link I can download?
    Thank you.

    ariefbayu wrote:
    Hi Guys,
    I need your help to restore my Z10 LE.
    It is bricked while doing OTA update. Currently, it stuck in installing process.
    After doing restart, it will install the updates and when reaching 100%, it stuck there.
    I've tried to reinstall using web updater and BB Link. But, no result. Both method report that there is no update available for my BB. I guess, they think my BB already updated.
    I trying to install using sachesi. However, I'm not sure what parameter should I use to find the perfect ROM.
    Can you guys help me fill the parameter? or... maybe there is a direct link I can download?
    Thank you.
    When you are doing an update, you should not interrupt it.
    The update process for the BB10 can be quite long, I remember on of the last one that I did took nearly 1hrs being stuck at 100% before it then let me used the phone again.
    What I would suggest in your case would be to go to http://www.blackberry.com/updates, and do the update directly from there, again follow the instruction and do not interrupt the process
    Using the Playbook and the Z10 and the Z30 and loving them
    Martin

  • HT4623 I tried doing my update and it told me I don't have enough storage, so I deleted all of my apps, photos, videos, and music. And it's saying I still don't have enough storage. Any suggestions?

    I tried doing my update and it told me I don't have enough storage, so I deleted all of my apps, photos, videos, and music and I still don't have enough storage. Any suggestions?

    Do you memeber the complete wording of the error message?
    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iPod fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - If still not successful that indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar

  • I took my phone off the charger and wifi while it was updating and now it wont let me on the phone nor my computer. how do i get it to finish updating or turn on?

    i took my phone off the charger and wifi while it was updating and now it wont let me on the phone nor my computer and it just has the apple icon on the screen. how do i get it to finish updating or turn on?

    Why would you do that when your phone is updating?
    Your phone is in recovery mode If you can't update or restore your iOS device

  • My macbook pro keeps booting up, then after a few seconds, goes back to the sign in page. This happened after I was doing software updates and my computer restarted in the middle of an update. Help! Thanks.

    My macbook pro keeps booting up, then after a few seconds, goes back to the sign in page. This happened after I was doing software updates and my computer restarted in the middle of an update. Help! Thanks.

    Start up in Safe Mode.
    http://support.apple.com/kb/ph14204
    Repair Disk    Section: "Try Disk Utility"
    http://support.apple.com/en-us/HT203176

  • Error while doing Challan updation

    Dear all,
       Iam getting error while doing Challan updation, system shows an error saying "No line Item exist for Challan updation" whereas iam having all the data but the system is not picking.
    pls help on this
    will get a good points for solving this

    I understood ur problem, u r running the J1INCHLN when u r running this program . Program chks both the Table BSEG & WITH_ITEM they 2 field from BSEG-BUZEI & WITH_ITEM -J_1IBUZEI . if this 2 line item is not matching then system will show the same error which u have mentioned.
    Whether this has occured first time or rarely it occurs, if first then just update the table WITH_ITEM for the field J_1IBUZEI with respect to BSEG-BUZEI for the TDS line item only. Make the changes with help of ur Internal consultant. write an update program.

  • Control multiple updates and queries within one transaction in JPA

    Hi,
    I have a question regarding control multiple updates and queries within one transaction. We are using EclipseLink 2.3.1. With below code, will I be able to:
    - have all insert, update, select queries committed in one transaction;
    - queryGetBalance will return the latest OrgBalance after update;
    - if one fails, everything rolls back.
    Thanks!
    Jeffrey
    PS: I realized that I cannot use em.getTransaction().begin() and em.getTransaction().commit(), since I am using JTA.
    =============
    @PersistenceContext(unitName="Test")
    EntityManager em;
    em.setFlushMode(FlushModeType.COMMIT);
    newTransaction.setAmount(1000);
    newTransaction.setType("check");
    em.persist(newTransaction);
    orgAudit.setUpdateUser("Joe")
    orgAudit.setupUpdateTime(time);
    em.merge(orgAudit);
    Query queryUpdateBalance = em.createQuery("update OrgBalance o set o.balance = o.balance + :amount where orgId = :myOrgId");
    queryUpdateBalance.setParameter("amount", 1000);
    queryUpdateBalance.setParameter("myOrgId", 1234);
    Query queryGetBalance = em.createQuery("select OrgBalance o where o.orgId = :myOrgId");
    queryGetBalance.setHint("javax.persistence.cache.storeMode", CacheStoreMode.REFRESH);
    queryGetBalance.setHint("javax.persistence.cache.retrieveMode", CacheRetrieveMode.BYPASS);
    queryGetBalance.getResultList();
    em.flush();
    Edited by: JeffreyW on Dec 12, 2011 10:34 AM

    Yes, the operation will be in a single transaction, assuming you are using a JTA managed SessionBean and the code is part of a SessionBean method.

  • My ipad 2 disconnects while trying to update and cant complete syncing / copying of apps.

    Recently My ipad 2 has not been able to get a full charge and after repeat attempts manages a 95% charge. i updated to iOS 8.1.3. and my ipad disconnects while trying to update and cant complete syncing / copying of apps. it just keeps rebooting itself!

    Howdy frakie,
    If you are having an issue with your iPad restarting itself, I would suggest that you troubleshoot using the steps in this article - 
    If your iOS device restarts, displays the Apple logo, or powers off while you're using it - Apple Support
    In particular, since you are already using the latest version of the operating system -
    If you still see this issue after updating, contact Apple Support.
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • E52 Date Display does not update and reflect the c...

    Right from day 1 the display date of my E52 does not update and reflect correct the correct date. Got the phone replaced once still the same issue. Called the customer service and they say there is no such problem with E52. They asked me to go to the repair center...(isnt that ridiculous to ask a customer of a new phone to do so?). I went to the repair center with a hope that they will replace it for me but all in vain. They also gave me a ridiculous answer that Nokia does not have a replacement policy...and I was like so is it Nokia's policy to sell broken and faulty mobiles? I was utterly dejected. The electronic store where I bought also refuse to replace because they think there is a problem and no matter I get it changed it will recur. I still do not have a solution as all my ways of getting this problem resolved are exhausted. Anyone has a solution or came across this issue which can be solved without repairing?

    Ok let me state my problem. There is a date display and at midnight the date should automatically change to the next date. However that does not happen. The dealer makes the following changes Control Panel>Settings>General>Date and time> Automatic time update> On and this does not solve the problem. Then I get the mobile replaced and that too has the same problem. after going through all permutations and combinations the problem persists. To quote the email from the Contact center for Nokia in HK this was what was suggested
    Menu→Ctrl. panel→Settings→General→Date and time→Time zone→please select Hong Kong→Automatic time update→please select Off
    However, if the situation still occurred by following the above settings, please be advised to bring your Nokia E52 along with the valid sales invoice to one of our Hong Kong Nokia Care Centres for the handset checking since we do not have such arrangement of replacing a new phone to you.
    Please help!!!

  • While doing an update my iphone my itunes balance disappeared.

    While doing an update on my phone, the balance on my itunes account balance disappeared. 

    Use this article: Use recovery mode - Apple Support
    Be advised, this will erase all the data from your device.  But, then, restore the iCloud or iTunes backup of your iPhone you made prior to updating the iOS.  You'll get all your data back.

  • HT201210 I have tried to restore my i phone via itunes after doing the update and it keeps giving unknown error occurred (3194) please help

    I have tried to restore my i phone via  itunes after doing the update and it keeps giving unknown error occurred (3194) please help

    Hello Sam-marchesi,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    iTunes: Specific update-and-restore error messages and advanced troubleshooting
    http://support.apple.com/kb/TS3694#error3194
    Unable to contact the iOS software update server gs.apple.com
    Error 1004, 1013, 1638, 3014, 3194: These errors may be the result of the connection to gs.apple.com being redirected or blocked. Follow these steps to resolve these errors:
    Install the latest version of iTunes.
    Check security software and ensure that communication to gs.apple.com is allowed. Follow these stepsfor assistance with security software.
    Check the hosts file. The restore will fail if there is an active entry to redirect gs.apple.com. Follow theadvanced iTunes Store troubleshooting steps to edit the hosts file or revert to a default hosts file. See "Blocked by configuration: (Mac OS X/Windows) > Rebuild network information."
    Try to restore from another known-good computer and network.
    If the errors persist on another computer, the device may need service.
    Best of luck,
    Mario

Maybe you are looking for