Can I perform persistence activities from within a JPA lifecycle event

I have a question about what is valid while inside JPA lifecycle events like @PrePersist or even Eclipselink lifecycles like postBuild. I would like to perform persist and delete operations from within these lifecycles, however they seem to get lost when the commit finally happens at the end of the transaction.
Is this not valid...and if not how to I perform persistence operations from within these lifecycles. For example I may want to delete objects from a @PostDelete.
Thanks.

I don't see any reason why doing a persist() or remove() from instead a JPA PrePersist or PostRemove event would not work. What is your code for your event? Make sure you use the same EntityManager.
For the EclipseLink events, most of the write events are raised during the commit, so it is too late to perform a JPA operation such as persist(). You can however use EclipseLink DatabaseQuery to insert or delete objects, but you need to be careful doing this. In general it may be better to put this logic in your application instead of events.
James : http://www.eclipselink.org

Similar Messages

  • How can I execute an external program from within a button's event handler?

    I am using Tomcat ApacheTomcat 6.0.16 with Netbeans 6.1 (with the latest JDK/J2EE)
    I need to execute external programs from an event handler for a button on a JSF page (the program is compiled, and extremely fast compared both to plain java and especially stored procedures written in SQL).
    I tried what I'd do in a standalone program (as shown in the appended code), but it didn't work. Instead I received text saying the program couldn't be found. This error message comes even if I try the Windows command "dir". I thought with 'dir' I'd at least get the contents of the current working directory. :-(
    I can probably get by with cgi on Apache's httpd server (or, I understand tomcat supports cgi, but I have yet to get that to work either), but whatever I do I need to be able to do it from within the button's event handler. And if I resort to cgi, I must be able to maintain session jumping from one server to the other and back.
    So, then, how can I do this?
    Thanks
    Ted
    NB: The programs that I need to run do NOT take input from the user. Rather, my code in the web application processes user selections from selection controls, and a couple field controls, sanitizes the inoputs and places clean, safe data in a MySQL database, and then the external program I need to run gets safe data from the database, does some heavy duty number crunching, and puts the output data into the database. They are well insulated from mischeif.
    NB: In the following array_function_test.pl was placed in the same folder as the web application's jsp pages, (and I'd tried WEB-INF - with the same result), and I DID see the file in the application's war file.
            try {
                java.lang.ProcessBuilder pn = new java.lang.ProcessBuilder("array_function_test.pl");
                //pn.directory(new java.io.File("K:\\work"));
                java.lang.Process pr = pn.start();
                java.io.BufferedInputStream bis = (java.io.BufferedInputStream)pr.getInputStream();
                String tmp = new String("");
                byte b[] = new byte[1000];
                int i = 0;
                while (i != -1) {
                    bis.read(b);
                    tmp += new String(b);
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + tmp);
            } catch (java.io.IOException ex) {
                getSelectionsDisplayTextArea().setText(getSelectionsDisplayTextArea().getText() + "\n\n" + ex.getMessage());
            }

    Hi Fonsi!
    One way to execute an external program is to use the System Exec.vi. You find it in the functions pallet under Communication.
    /Thomas

  • Windows 8.1 PC, using reader, when searching a folder containing approx 100 doc's. If i search for a word, no results are returned. only the doc names can be found but nothing from within the doc. This is a new problem and was not the case before.

    Windows 8.1 PC, using reader, when searching a folder containing approx 100 doc's. If i search for a word, no results are returned. only the doc names can be found but nothing from within the doc.
    This is a new problem and was not the case before.

    Works perfectly fine for me with the latest Reader version (11.0.09).
    You write that it worked "before"; before what?  An update?  Update from what version to what version?

  • Can EJB's be called from within JSP pages?

    Hi,
    (This is a general question, not necessarily related to OAS in any way...)
    I have read/heard conflicting reports pertaining to calling EJBs from within JSP pages.
    Can anyone tell me if it's possible to reference an EJB session bean from a JSP page? Can anyone point me to some documentation on the topic?
    Any help would be appreciated. Thanks!
    David Christopher
    [email protected]

    Hi,
    Check the following code: http://www.jguru.com/jguru/faq/view.jsp?EID=5314 for ejb example.
    -Ruchi
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Davidc:
    Hi,
    (This is a general question, not necessarily related to OAS in any way...)
    I have read/heard conflicting reports pertaining to calling EJBs from within JSP pages.
    Can anyone tell me if it's possible to reference an EJB session bean from a JSP page? Can anyone point me to some documentation on the topic?
    Any help would be appreciated. Thanks!
    David Christopher
    [email protected]<HR></BLOCKQUOTE>
    null

  • Can 'Form Data' Be Called From Within A JavaScript?

    Hi,
    I'm trying to import form data from within a JavaScript. What would the following code be changed to, if my form data file was called "NewDoc"?
    n=app.alert("Are you sure you want to Reset?/Êtes-vous certain de vouloir recommencer?",2,1);
    if (n==1)
    this.resetForm();

    First you will need to set the other PDF's "disclosed" property to "true" so you can open it in the first PDF.
    Then you can modify the following code from example 3 for the "app.openDoc" method:
    oDoc = app.openDoc({
    cPath:"/C/myDocs/myInfo.pdf",
    bHidden: true
    }); // oepn other PDF
    var v = oDoc.getField("myTextField").value;
    this.getField("yourTextField").value = v; // get value of field in other document
    oDoc.closeDoc(); // close the other document

  • Can you Launch External Applications From Within InDesign Ebook?

    Hi all,
    I was wondering if it is possible to open an external application from within an ebook (created with InDesign) e.g. click on a link and have an external ssh client open up for instance?
    Thanks in advance for any advice.
    Regards,
    RG

    It's possible to include hyperlinks in an InDesign file and export them in an EPUB file. Since I'm not familiar with working with SSH clients (in fact, I just had to Google it to have a clue what you're talking about), is this something that can be invoked in a standard URL format? If so, you could probably include it.
    The next issue is whether the link would work. The link couldn't be used directly in any eBook reader I know of, but at least the iBook on an iPad or iPhone would switch to to Safari to let you follow a URL to its destination. But I don't think that's possible on most eBooks.

  • In Captivate 7, how can I call another action from within an action?

    I have a conditional action called FakeSuccessRewind. Now I need to call another function called ShowGrayBalloons02 from within its Else statement, but I couldn't find something like "Execute Advanced Action." Can anybody share some tips here? Thanks!
    Below are screenshots of my two actions:
    1) FakeSuccessRewind (if/else). Here I need to call the 2nd action from the Else statement, underneath the statement Go to the next slide.
    2) ShowGrayBalloons02. Note this function has five seperate runs when the variable is decrementing from 5-1.
    Thanks a lot!
    Melissa

    You can't, you need to add the other action into the first one.

  • Performing disk reads from within a kernel module

    Hi,
    i want to perform direct io reads from a specific disk from within a kernel module. i tried to perform a physio call, but although the function returns 0 (success) my buffer has not changed.
    any ideas or pointers to example code would be appreciated.
    Oren

    Hi,
    i want to perform direct io reads from a specific disk
    from within a kernel module. i tried to perform a
    physio call, but although the function returns 0
    (success) my buffer has not changed.
    any ideas or pointers to example code would be
    appreciated.
    OrenIt's kinda non-trivial... physio() might be not good enough as if your disk is SCSI it won't perform sync I/O for you - you'd better use the aphysio(), or get the dev_ops of the disk and call it's strategy directly...
    Do not forget to set completion (iodone) routine pointer in your buf structure - it'll be called upon I/O completion in asyncronous case. You might then wait on some CV in your I/O routine right after you've dispatched the strategy (either directly, or via aphysio), and in iodone() routine just signal the CV.
    Hope this helps,
    Ilya.

  • How can I access applet paramters from within javafx?

    I have a simple javafx applet from the clock tutorial, but I would like to initialise this from parameters that are specified in the <APPLET> tag, for exaple <param name="timeZone" value="America/Los_Angeles">My question is how do I access this parameter from within javafx?
    Thanks,
    Phil

    I'm looking for the same answer, if anybody knows ... ;)

  • Why can't I delete photos from within a smart folder?

    I setup smart folders to help me weed out certain types of bad photos. The problem is, now that I have collected these photos I am unable to "move to trash" from within a smart folder. Why do you suppose Apple did this? Every time I find a photo I need to delete, that is inside one of these smart folders, I have to return to the Photos library and try and track it down in there......then move it to trash.
    Any ideas?

    Perhaps you are hitting the wrong key combination?
    Command key is the Apple key. So you should be holding down the Apple key & the option key and while holding hit delete.
    Perhaps you are holding down Ctrl instead?
    Also, which keyboard do you have? I wonder if there is an issue with the laptop and new iMac shorty keyboards where delete and backspace are treated differently. The new keyboards do a "forward delete" by holding down the Fn key along with delete. Maybe something there is causing an issue?
    Patrick

  • Yosemite: can no longer rename files from within any apps?

    mavericks (and earlier versions of os x) allowed renaming filenames from within any app.
    this cannot be done in yosemite; is this correct (anyone please confirm)? or is this still a mac os x feature that got turned off during my updating somehow?
    if no longer available, is there a workaround to this extremely useful workflow tool?

    bump.
    anyone?

  • Can I compare two databases from within SQL Server Management Studio

    Hi everyone.  I haven't found anything online, so I wanted to ask here.  I have two SQL Server databases running on our server.  One is the production database, and another is my development database that I use when I'm working on the program. 
    I add tables and columns and stuff to my development database, and was wondering if anyone knew of an easy way to from within Management Studio or something to compare the two databases to make sure that they are the same and show me any differences. 
    I generally add tables or columns to both databases at the same time, but I worry that one time I might forget, so I would like to be able to run some sort of compare / check to make sure before releases...
    Thanks everyone for your help.  I greatly appreciate it.

    There is a command line utility that is with Microsoft SQL Management Studio called
    tablediff:
    http://msdn.microsoft.com/en-us/library/ms162843%28v=sql.105%29.aspx
    An example:
    http://www.mssqltips.com/sqlservertip/1073/sql-server-tablediff-command-line-utility/
    And using it with multiple tables at once looks like some work but doable:
    http://blogs.msdn.com/b/repltalk/archive/2010/02/21/how-to-run-tablediff-utility-for-all-replicated-published-tables-in-sql-2005-or-sql-2008.aspx
    ...and some custom code to implement in an answer at StackOverflow:
    http://stackoverflow.com/questions/10688/best-tool-for-auto-generating-sql-change-scripts-for-sql-server?rq=1

  • Why can I only purchase movies from within my own country?

    Or moreover, Why can't I buy movies from the ITunes family in other countries?

    You can ONLY buy from the itunes store of the country of your residence ( proven by the billing address on your credit card) and ONLY while inside the borders of that country.

  • Can you run a workflow from within iPhoto?

    I've created an automator workflow service which adds a date stamp to photos.  In finder I right click on a .jpg file, and the select "Services -> Add date stamp to photo.
    Is it possible to run workflows, i.e., user created services from withing iPhoto?  I tried creating a service in automator which simply has a "Play iPhoto Slideshow" action and runs in "iPhoto.app", but when I run iPhoto and select an image, then select Services from the iPhoto menu, it is not visible.
    -Thanks

    My date script adds a small visible date to the actual photo itself based on the EXIF date tag.  The batch command just changes the date of the file itself, I belive.  Actually, it is possible to create automator workflow services which act on photos within iPhoto.  You can see three below in the iPhoto Services menu that I've created, which I now use regularly.

  • Can't print a report from within web application

    <p>I can run the report within Eclipse and it displays fine.  When I click the export button a modal window comes up and all works as expeced.  If I click the print button then a modal box comes up but it is blank except for a little white square up in the top left corner.</p><p>When I view the html source in the browser, the displayPrintDialog function makes reference to active X print control.</p><p>prm.codebase = "../ActiveXControls/PrintControl.cab";</p><p>but I don&#39;t have that within my web application. </p><p>Is there something that I need to install on this machine to get printing to work?</p><p>Any help would be greatly appreciated.</p><p>Marty Jones </p><p> </p>

    <p>Unfortunately the ActiveX print control was not validated with the CR4E version of the Java Reporting Component. Therefore users must implement the prininting via the PDF print option. The print option is determined by the printMode property of the viewer. The default should be PDF but if you want to ensure that it always uses PDF you can set the following code using our API:</p><p> crystalReportPageViewer.setPrintMode(CrPrintMode.PDF);</p><p>If you are using the Tag Libraries you should set the property printMode equal to PDF.</p><p>Hopefully, in a future release we can look at adding in a "pure" print option again. </p><p>Regards,<br />Sean Johnson (CR4E Product Manager) </p>

Maybe you are looking for

  • Logical Filename

    Hi all, We have a Z-transaction used to perform requests by using a DTP process and send them to a file (SAP schedules jobs automatically for doing this). The name of this file should determined at runtime using a variable from the Z program. We foll

  • Fixed Cost Element Group

    Hi, In the Cost Center Actual/Actual Compariosn report I want "COST ELEMENT GROUP" to be fixed to 1000 when ever the report is executing. how can i do it? Thnaks Best Regards Gayani

  • Making a complex text editor.

    I put together a text editor that has all of the basic functions cut, copy, paste, save, open, and some other stuff. Here is the problem: I want to make it so it can display several different fonts, font sizes, and font colors, at once. I have a feel

  • IPad2 Netflix not playing movies

    Recently my iPad2 Netflix app hasn't been playing movies.  The app loads, I can press play on a movie, it buffs but it never plays the video or sound.  I can fast forward and see the small preview of the fast forward but when I stop it still doesn't

  • Posting rule - Cheque Bounce - Bank Statement Processing

    Hi friends, I am configuring for bank statement processing.  Among the posting rules I have to set, I am doubtful about the posting rule (debit, cridit, & account symbol.) for the 'cheque deposited bounced' & 'cheque issued bounced' transaction. Kind