How to execute our own Insert Query using EJB3.0 and Toplink

Hi,
This is my scenario. I want to insert master record and then detail record.
Initially i followed this way
UnitOfWork uow = getSessionFactory().acquireUnitOfWork();
final EgovAgencyDetails egovAgency =
(EgovAgencyDetails)uow.executeQuery("findAgencyRegistrationNo",
EgovAgencyDetails.class, eGovPOMasterBean.getAgencyRegistrationNo());
EgvoPaymentorderMaster po = (EgvoPaymentorderMaster)uow.newInstance
(EgvoPaymentorderMaster.class);
po.setSupplierName(-----);
uow.commit();
Then i inserted detail record. the same find the master record and then inserted detail record in the table.
But if detail record fails means i want to rollback the master record.
For that i followed below steps in my custom method in session facade,
SQLCall sqlCall = new SQLCall("INSERT INTO EMPLOYEE (L_NAME) VALUES (#last_name)");
UpdateObjectQuery query = new UpdateObjectQuery(myEmployee);
query.setCall(sqlCall);
query.addArgument("last_name"); // input
query.bindAllParameters();
Vector arguments = new Vector();
arguments.add("MacDonald");
uow.executeQuery(query, arguments);
final EgvoPaymentorderMaster poMaster =
(EgvoPaymentorderMaster)uow.executeQuery("findEgovPOID", EgvoPaymentorderMaster.class, eGovPOMasterBean.getPoNumber());
EgovPaymentorderDetail poDetailInstance = (EgovPaymentorderDetail)uow.newInstance
(EgovPaymentorderDetail.class);
poMaster .addEgovPaymentorderDetail(poDetailInstance);
Since if detail record failed means i want to rollback.
I am getting this exception. Pleas kindly provide what changes i need to do.
[TopLink Warning]: 2008.03.15 01:05:48.931--UnitOfWork(12731542)--Exception [TOPLINK-6014] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070608)): oracle.toplink.exceptions.QueryException
Exception Description: Objects cannot be written during a UnitOfWork, they must be registered.
Query: WriteObjectQuery(mof.egov.model.EgvoPaymentorderMaster@126df42)
08/03/15 13:05:48 --- Inside Catch Method --- :
Exception Description: Objects cannot be written during a UnitOfWork, they must be registered.
Query: WriteObjectQuery(mof.egov.model.EgvoPaymentorderMaster@126df42)
Local Exception Stack:
Exception [TOPLINK-6014] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070608)): oracle.toplink.exceptions.QueryException
Exception Description: Objects cannot be written during a UnitOfWork, they must be registered.
Query: WriteObjectQuery(mof.egov.model.EgvoPaymentorderMaster@126df42)
     at oracle.toplink.exceptions.QueryException.invalidQuery(QueryException.java:536)
     at oracle.toplink.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:86)
     at oracle.toplink.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:72)
     at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2604)
     at oracle.toplink.publicinterface.Session.executeQuery(Session.java:993)
     at oracle.toplink.publicinterface.Session.executeQuery(Session.java:965)
     at mof.egov.model.MasterDetailSessionEJBBean.insertPaymentOrder(MasterDetailSessionEJBBean.java:391)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
Thanks & Regards
Vimalan Balan

C,
I don't use TopLink, but I suggest you set the "processEscapes" [Oracle database connection] property to "true", as described in the JDBC User's Guide and Reference.
Oracle documentation can be accessed from here:
http://www.oracle.com/technology/documentation/index.html
Good Luck,
Avi.

Similar Messages

  • Insert into date column using EJB3.0 and toplink not working

    Hi All,
    I'm getting the following error whenever I attempt to insert a date value into my Oracle database.
    [TopLink Fine]: 2006.08.08 05:53:21.973--UnitOfWork(14806807)--Connection(14714759)--Thread(Thread[RMICallHand
    ler-0,5,RequestThreadGroup])--
    INSERT INTO EMP (EMPNO, ENAME, SAL, HIRE_DATE) VALUES (156, 'John', 2.0, {ts '2006-08-08 17:53:21.973'})
    [TopLink Warning]: 2006.08.08 05:53:22.036--UnitOfWork(14806807)--Thread(Thread[RMICallHandler-0,5,RequestThreadGroup])--
    Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)):
    oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00904: invalid column name
    The cause seems to be clear enough; from the sql above it seems that the timestamp syntax isn't being interpreted properly by either toplink or the JDBC driver , (I'm using whatever driver that comes with OC4J 10.1.3).
    I've seen somewhere that you can call setUseNativeSQL() in toplink but how do I get hold of the toplink session from an entity bean?
    That sounds like an awkward workaround anyway, what other workarounds are open to us?
    Thanks,
    C

    C,
    I don't use TopLink, but I suggest you set the "processEscapes" [Oracle database connection] property to "true", as described in the JDBC User's Guide and Reference.
    Oracle documentation can be accessed from here:
    http://www.oracle.com/technology/documentation/index.html
    Good Luck,
    Avi.

  • How to create an object of our own class by using Class.forName()??

    how to create an object of our own class by using Class.forName()??
    plzz anser my qustion soon..

    Class.forName does not create an object. It returns a reference to the Class object that describes the metadata for the class in question--what methods and fields it has, etc.
    To create an object--regardless of whether it's your class or some other class--you could call newInstance on the Class object returned from Class.forName, BUT only if that class has a no-arg constructor that you want to call.
    Class<MyClass> clazz = Class.forName("com.mycompany.MyClass");
    MyClass mine = clazz.newInstance();If you want to use a constructor that takes parameters, you'll have to use java.lang.reflect.Constructor.
    Google for java reflection tutorial for more details.
    BUT reflection is often abused, and often employe when not needed. Why is it that you think you need this?

  • How to develop our own provisoning process

    Hi,
    Please tell me step by step how to develop our own provisioning process .

    try below
    1. create it resource
    2. create Resource Object
    3. create Process Form using Form designer
    4. Create adapters (You must have java code ready)
    5. create Process Definition
    6. add process task by associating adapter under process definition
    below link will help to do above
    http://docs.oracle.com/cd/E14571_01/doc.1111/e14309.pdf
    Its better Go with OOTB connector and see how OOTB works and that will give you the proper idea
    You can install any OOTB connector for this
    regards,
    Nishith Nayan
    Edited by: Nishith Nayan on Jan 30, 2012 10:08 PM

  • In DBI , how to find out the Source Query used for the Report

    Hi All,
    How to find out the Source Query used to display the data in the DBI Reports or Dashboards. We can get it in Apps Front end by Going to Help and Record Histroty. But DBI Runs in Internet Explorer so i dont know how to get the source query ( SELECT Query ) Used.
    In IE we have View --> Source . But that does not help since it gives the HTML Coding and not the SELECT Query used.
    If anyone has ever worked on it...Please help me in finding it.
    Thanks,
    Neeraj Shrivastava

    Hi neeraj,
    You can see the query used to display reports.Follow these steps to get the query.
    1)Login to oracle apps
    2)Select "Daily Business Intelligence Administrator" responsiblity.
    3)Now click on "Enable/Disable Debugging" (Now u enabled debugging)
    4)now open the report which you want to see the query of
    5)In view source it displays query along with the bind varilables.
    Feel free to ping me if you have any doubts
    thanks
    kittu

  • How do i know if my query using  SORT_AREA_SIZE   or temporary tablespace ?

    Good Morning  Everyone !
    My DB version is 10.2.0.1
    I have large table  exactly 3 million records.
    SQL> select count(*) from tab1;
    COUNT(*)
       300000
    SQL> select * from tab1 order by no DESC;
    sorting  ... in process
    300000 rows selected.
    in Terminal 2 : I tried to find  sorting details -   ( No rows  selected - why ? )
    SQL> select USERNAME , USER , TABLESPACE , SQL_ID from v$tempseg_usage  ;
    no rows selected
    SQL> /
    no rows selected
    When i google i have seen this ;
    If  Oracle cannot do the sort in memory  (SORT_AREA_SIZE initialisation parameter), space will be allocated in a temporary tablespace for doing the sort operation.
    REF_LINK : TEMPORARY Tablespaces and TEMPFILES | Oracle FAQ
    MY DOUBT QUESTION :   How do i know if my query using  SORT_AREA_SIZE   or temporary tablespace ?
    Thanks in advance.

    @ JohnWatson
    I have seen some articles from ORA - FAQ. Good.
    SQL> select USERNAME , USER , TABLESPACE , SQL_ID from v$tempseg_usage;
    USERNAME                       USER   TABLESPACE                      SQL_ID
       SCOTT                               SYS          TEMP                            fh9vqgyd6m0d1
    PGA management means that sorting only 300000 rows  may well occur in memory
                Is this (3 million rows) -  standard  value for 10g version ?
    Thanks JohnWatson

  • How to create search function (af:query) using method in java

    hi All..:)
    i got problem with search custom (af:query), how to create search function/ af:query using method in java class?
    anyone help me....
    thx
    agungdmt

    Hi,
    download the ADF Faces component demo sources from here: http://www.oracle.com/technetwork/testcontent/adf-faces-rc-demo-083799.html It also has an example for creating a custom af:query model
    Frank

  • How to add our own applications to Cisco Connect Cloud?

    How to add our own applications to Cisco Connect Cloud?

    You might find this interesting.
    http://newsroom.cisco.com/press-release-content?type=webcontent&articleId=926074
    Interested developers are invited to visit the Linksys Developer Community at http://developer.cisco.com/web/ldc to register and develop apps for Linksys Smart Wi-Fi Routers. Cisco empowers developers with technical, marketing, and sales resources to help support every phase of their developmental and business cycles.

  • I need to play a song on a Keynote presentation, how do I do this ? I use to drag and drop the mp3 in Keynote but it stops playing when the slide move to the other one... how can I make the song keep playing through the whole presentation ? Thanks.

    I need to play a song in a row in a Keynote presentation, how do I do this ? I use to drag and drop the mp3 in Keynote but it stops playing when the slide move to the other one... how can I make the song keep playing through out the presentation ?
    Thanks.

    Drag the file into the audio window in the Document inspector...

  • How to get resultset from oracle procedure use ejb3

    how to get resultset from oracle procedure use ejb3
    i know oracle procedure should like this
    Create or replace PROCEDURE resultset_test(
    aaa IN NUMBER,
    bbb OUT sys_refcursor) ....
    but what s the ejb3 scripts looks like? please give me an example or link~
    ths

    - there are no EJB3 scripts, only compiled application code
    - the part of the EJB spec that deals with databases is called the Java Persistence API, but likely you are just looking for the JDBC API.
    Now you should know what to Google to get your "example script": "java jdbc oracle procedure"

  • How to upload a file into server using j2ee jsp and servlet with bean?

    How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
    Anyone help me please!

    u don't need j2ee and struts to do file uploading. An example is as such
    in JSP. u use the <input> file tag like
    <input type="file"....>You need a bean to capture the file contents like
    class FileUploadObj {
        private FormFile srcFile;
        private byte[] fileContent;
        // all the getter and setter methods
    }Then in the servlet, you process the file for uploading
        * The following loads the uploaded binary data into a byte Array.
        FileUploadObj form = new FileUploadObj();
        byte[] byteArr = null;
        if (form.signFile != null) {
            int filesize = form.srcFile.getFileSize();
            byteArr = new byte[filesize];
            ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
            bytein.read(byteArr);
            bytein.close();
            form.setFileContent(byteArr);
        // Write file content using Writer class into the destination file in the server.
        ...

  • HT204350 Incorrect link to "OS X: How to migrate data from another Mac using Mountain Lion and earlier"

    Incorrect link to "OS X: How to migrate data from another Mac using Mountain Lion and earlier". Should be http://support.apple.com/kb/HT6025

    I think the OP is saying OS X: How to migrate data from another Mac using Mountain Lion and earlier (which should be a link to HT4889) just links back to OS X: How to migrate data from another Mac using Mavericks (HT5872).
    It does indeed do that, & HT4889 seems to be MIA.

  • HT1338 Yesterday, I purchased Mountain Lion OSX and tried to download it but I don't think it worked.  How can I tell if I am using Mountain Lion and how do I get help if the download was unsuccessful?

    Yesterday, I purchased Mountain Lion OSX and tried to download it but I don't think the download worked.  How can I tell if I am using Mountain Lion and how do I get help if the download was unsuccessful?

    Click your Apple menu icon top left corner of your screen.
    From the drop down menu click About This Mac.
    If Mountain Lion is installed, it will say:  v10.8
    If not, launch the App Store. From the App Store menu bar click Store > Check for Unfinished Downloads
    FYI ..  for downloading Mountain Lion from the App Store, a high speed (broadband) internet connection is strongly recommended by Apple as noted here > iTUNES STORE - MAC APP STORE - TERMS AND CONDITIONS
    If you need to reinstall OS X or repair the the startup disk Mountain Lion Recovery, that requires broadband access to the internet via Wi-Fi or an Ethernet connection. OS X is downloaded over the internet form Apple when OS X Recovery is used for reinstallation.

  • When I open a pdf file, after a few seconds, it hides the toolbar and I don't know how to get it back.  I use multiple monitors and, without being able to grab the toolbar, I am unable to move the pdf file to a different monitor.  How do I stop this?

    When I open a pdf file, after a few seconds, it hides the toolbar and I don't know how to get it back.  I use multiple monitors and, without being able to grab the toolbar, I am unable to move the pdf file to a different monitor.  How do I stop this?

    Does Firefox switch to full screen if you press F11 ?
    You can also try the F10 key to see if that brings up the menu bar.
    * If the above steps didn't help then see http://kb.mozillazine.org/Corrupt_localstore.rdf
    Note: Do not delete localstore.rdf in the program folder (Windows: "C:\Program Files\Mozilla Firefox\defaults\profile\") (Mac: "/Applications/Firefox.app/defaults/profile/")

  • Not receiving mail sent to and from my own accounts! using latest OS8 and X10.9.5.Using Apple Mail account. Used to be able to do this!

    Not receiving mail sent to and from my own accounts! using latest OS8 and X10.9.5.Using Apple Mail account. Used to be able to do this!

    My system is OS8 and X10.9.5

Maybe you are looking for