Flush before executeQuery

Hi,
we're using toplink 9.0.4.8 and we've often had problems with incorrect query results if conformResultsInUnitOfWork is set.
With topling 10.1.3 being the reference implementation for ejb 3.0., I assume following holds true:
3.5.2 Queries and FlushMode
The flush mode setting affects the result of a query as follows.
When queries are executed within a transaction, if FlushMode.AUTO is set on the Query object, or if
the flush mode setting for the persistence context is AUTO (the default) and a flush mode setting has not been specified for the Query object, the persistence provider is responsible for ensuring that all updates to the state of all entities in the persistence context which could potentially affect the result of the query are visible to the processing of the query. The persistence provider implementation may achieve this by flushing those entities to the database or by some other means.
How is this achieved in toplink? Still by checking the unitOfWork cache or by flushing to the db?
I've updated to 10.1.3 and tried calling unitOfWork.writeChanges before the query but it produced an exception when executing the query - something in the line of "no object queries allowed now that you've started doing something with the db".
So I guess that's not the "flush" I'm looking for.
Is there another way or do I have to rely on the conformResultsInUnitOfWork? In the latter case, I'm pretty sure we've found another bug in it :-)
Ana

Thank you!
So I can use the flush() method and then execute a query? Do I have to use the EntityManager API for this or is flush() the same as writeChanges() in UnitOfWork?

Similar Messages

  • System.out will not flush before input

    Hello everyone,
    I am using Netbeans 5.5, JDK6, and J2EE. I am new to the environment so I wrote a test application that would prompt a user to enter a string and then echo it. I have:
    String str = "";
    BufferedReader br = new BufferedReader(new nputStreamReader(System.in));
    System.out.print("Enter a string: ");
    System.out.flush();
    try
    str = br.readLine();
    catch(IOException ex)
    System.out.print(ex.toString());
    System.out.print(str);
    What is really bizarre is that System.out will NOT flush no matter what. My application will always ask for input before it even prompts the user for the string. This is what the output looks like when running:
    init:
    deps-jar:
    compile:
    run:
    hello
    Enter an string: hello
    BUILD SUCCESSFUL (total time: 5 seconds)
    Notice how I had to enter the string first? The only way that I have seen that it flushes is if I used println() instead of print. But what if I don't want the prompt to have an end line in it. This just seems like weird behavior. Also, I have tried using a Scanner for input and the results are the same. Not really sure what to do. Any help would be most appreciated. Thanks.

    are you running this inside netbeans as well? the "console" view in netbeans (and eclipse, and probably other IDEs) is not a real console, it's a GUI component that the IDE writes to. it's behaviour isn't guaranteed to act like a real console. I've seen this sort of thing on eclipse before, but never used netbeans. but it still stands that an IDE's console view isn't an actual console/terminal window. that may well be the root of the problem

  • May i use nls_charset12 to convert character set before executeQuery()?

    i got a problem for the db nls character set
    isn't us7ascii, so while retreiving data from database the data stored in ResultSet is changed to UTF-8 format. thus, my question is - how to convert character set before my executuing the method
    executeQuery() or any other methods would be appreciated.
    thanks in advice,

    This is Tommy. I saw your post on Oracle Forum. Can you give me the classes12.zip, classes12_g.zip, and nls_charset12.zip ?!
    Thx in advance !!
    Tommy fromTaiwan ( July 3, 2001 )

  • Flushing a SocketChannel before close()

    Hi,
    I wrote a simple http server using java.nio. I've run into a problem where occasionally, calling close() on the SocketChannel closes the socket prematurely, before all the response bytes have been sent to the client. Is there a way to ensure that the SocketChannel flushes before closing?
    Thanks
    Yariv

    close calls flush.
    A socket connect holds data after the connect is closed to ensure data is recieved by the client.
    If you want to be really sure the client has recieved data before closing it, send the client a message which causes the client to close the connection.

  • Flush file before writing using UTL_FILE

    Hi,
    Version: 10g
    I am using the UTL_FILE.PUT_LINE to write some data into a file.
    Now my requirement is to flush this file before every write. Is there a function/procedure which does this?
    Require help ASAP.
    Thanks in advance.

    Why flush before a write? The write buffer will be empty. And there will be nothing to flush.
    You need to flush after a write in order to flush that write buffer to disk.
    You also need to ask yourself why you want to do this? Write caches/lazy writes improve performance. The primary reason for flushing a cache is to ensure that the cache contents are on disk in case the process dies and its dirty unwritten cache is destroyed with it.
    Do you expect your process to crash and die? If not, then what other reasons do you think warrants flushing the cache after each write?

  • Flush?

    Hi All,
    I implemented the "Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)" blog.
    An exception: "you must flush before accessing the resource content" occurs.
    Any ideas on how to overcome this problem?
    Regards,
    Motaz

    Hi Motaz,
          The above code is deprecated :-
    Replace that with this piece of code -->
    File f = new File(fileName);
    WritableWorkbook workbook = Workbook.createWorkbook(f);
    FileInputStream excelCSVFile = new FileInputStream(f);
    *IWDResource cachedExcelResource = WDResourceFactory.createCachedResource(excelCSVFile, "FileName.xls", WDWebResourceType.XLS, false);*
    wdContext.currentContextElement().setResource(cachedExcelResource);
    cachedExcelResource.getUrl(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal());
    WDFileDownloadBehaviour --> Will determine how you would like to download your file.
    Hope this helps !!!
    Cheers,
    Brian.

  • Problem with flush=true in the jsp:include tag

    Hello
    I have deployed a JSP based application , based on the apache struts framework. The web server is Sun One Webserver 6 Service Pack4, on a windows 2000 machine
    The same application was tried on SunONE application server 7, and it works without any problem. However in this case the following error , on the page
    javax:servlet.jspexception:Illegal to flush within a custom tag
    Does this mean flush="true" is not allowed within custom tags
    Or is there a workaround for this
    Any help is appreciated
    thanks
    - Aniruddha

    Hi,
    This is a known problem, ��flush before you include�� limitation in JSP 1.1.
    As a result, you have to state flush="true" every time you include a jsp using <jsp:include> tag if you are using JSP1.1.
    Fortunately, it is fixed in JSP1.2. The flush attribute controls flushing. If true, then, if the page output is buffered and the flush attribute is given a ��true�� value, then the buffer is flushed prior to the inclusion, otherwise the buffer is not flushed. The default value for the flush attribute is ��false��.
    Gary Wang
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Flush in the jsp:include tag

    should I state flush="true" every time I include a jsp using <jsp:include> tag in a jsp pages? For example I am trying to include a menu bar on the top of every jsp pages. Should I flush the buffer every time? if not, will it affect the performance?
    Thank you
    Cal

    Hi,
    This is a known problem, ��flush before you include�� limitation in JSP 1.1.
    As a result, you have to state flush="true" every time you include a jsp using <jsp:include> tag if you are using JSP1.1.
    Fortunately, it is fixed in JSP1.2. The flush attribute controls flushing. If true, then, if the page output is buffered and the flush attribute is given a ��true�� value, then the buffer is flushed prior to the inclusion, otherwise the buffer is not flushed. The default value for the flush attribute is ��false��.
    Gary Wang
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Usage of BufferedInputStream & OutputStream#flush()

    I have a snippet below.
    InputStream fileInputStream = formFile.getInputStream();//org.apache.struts.upload.FormFile
    OutputStream out = = new BufferedOutputStream(new FileOutputStream(tempFilePath));
    byte[] buffer = new byte[256 * 1024];
    int contentLength;
    while ((contentLength = fileInputStream.read(buffer)) > 0) {
    out.write(buffer, 0, contentLength);
    out.close();
    fileInputStream.close();1. Should I use BufferedInputStream wrapping around formFile.getInputStream() ? I upload huge size files, say > 500 MB.
    2. Should I really call out.flush() somewhere ? If yes, should it be inside while loop or after while loop ?
    thanks in advance.

    baskark wrote:
    Otherwise, there's no need to call it. If you're already done writing, you'll call close(), and that will call flush() anyway. If you're writing all of the data in chunks one right after the other, and not stopping to do other processing between chunks, then you'll be writing as fast as possible and calling close() right away anyway, so, again, no benefit to calling flush.Will calling flush() before calling next write() make a difference in performance ?Calling flush unnecessarily could potentially slow things down, but you'd probably have to do a lot of it to be noticeable.
    Also using BufferedInputStream wrapping around formFile.getInputStream() improves performance in anyway ?If you're reading in large chunks with read(byte[]), it probably won't make a difference. But if you're reading into a very small byte array, or reading one byte at a time with read(), then using the BufferedInputStream will be baster.

  • Preventing servlet output stream to flush

    I increased the buffersize in the response object in order to make it possible for the entire jsp page to process before writing any output to the webclient.
    BUT since I use dynamic jsp-includes I fail to accomplish this, since according to the JSP1.3 specification the output stream is flushed before processing a dynamic include instruction.
    Is there a way I can make JSP to process the include and write output to buffer WITHOUT flushing it?
    Regards, Jon

    No I am using JSP 1.3. And I want to do the following:<%
    for (int i = 0; i < 5; i++) {
       // include("file_"+ i +".jsp");
    %>This to include file_0.jsp up to file_4.jsp.
    I assume the <jsp:include>tag is preprocessed hence only included once.

  • When handling local files , should I call flush() at all?

    When handling local files, I am confused by the flush() method.
    A lot of tutorial pages say it's safer to call flush() before close(). After thinking for a while, I'm asking mysel: Does flush() applies only to buffered stream(right?)? If a stream is not buffered, program should not call flush(). For buffered stream, the corresponding close() method of the wrapper or stream class should invoke flush() method. If they don't , it's an implementation bug, which should be fixed. So for both buffered and unbuffered stream, no need to call flush() before close()(right?).
    Then the question is: when do we need to call flush() method? If we don't need call flush() at all, why are there flush() methods in almost every stream/wrapper class?
    Please let me know what is wrong, either me or something else.
    Any feedback is appreciated.
    Gang

    "The close method of FilterOutputStream calls its flush method, and then calls the close method of its underlying output stream." (Javadoc)
    By inheritance this also applies to BufferedOutputStream and its descendants. However FileOutputStream does not extend FOS or BOS so it has nothing to flush(), so flushing it does nothing at any time even before closing.
    In general flush() writes buffered bytes out of the JVM into the operating system. When you do have buffering, which in practice you should (e.g. new BufferedOutputStream(new FileOutputStream(...))), you should flush at points when you really want to be rid of the data. When operating on sockets you should always flush before try to read the next data from the socket. You can flush more often if you like but it is often counter-productive.

  • Unable to load file ..jsp

    Hi
    When Iam forwarding a jsp page to other jsp page after
    some condition meets using jsp forward than some times
    when i access it it gives
    "Unable to load as it is not a top level class"
    for file while is forwarded
    for example:--
    <jsp:forward page="Login.jsp">
    <jsp:param name="user" value="<%=user%>"/>
    </jsp:forward>
    it gives login.jsp not a top level class
    unable to load
    note :---- all files in one directory
    suggestion required

    actually it depends on your JSP engine. I'm not sure but I've a doubt that once you have flushed some response , you may get an error in forwarding ( in some of the jsp engines, but I think in tomcat it's fine).
    you could try by using "buffer" property in such a way that no response is flushed before you forward the JSP page.

  • Not able to set the where clause params

    Hi,
    My version of apps is 12.1.3.
    I created a page with a searchRN and resultRN (LinesVO). (Not a query/view link) . I am passing the id from header to the VO to restrict the linesVO
    The controller correctly passes the id from searchRN to AM, but in AM, the where clause is not set and I am not getting the desired result:
    My AM Code:
        public void InvokeGo(String Hdrval)
                    LineVOImpl LineVO1 = getLineVO1();
                    LineVO1.setWhereClauseParams(null); // Always reset
                     System.out.println("AMIMPL:Hdrval = "+ Hdrval);
                    <prints the header_Value which is passed from CO>
                       if (Hdrval           == null        
                                            System.out.println("Inside Null If");  
                                            String message = "Please provide atleast one input to any of these search field";
                                            throw new OAException(message, OAException.ERROR);
                                    else   
                                        System.out.println("Not All Parameters are Null.Building Where Clause");
                                         < prints the line above>
                                        LineVO1.setWhereClause
                                        ("Header_name = :1");
                        System.out.println("Paremeter Set are: Header_name:"+Hdrval);
                        <prints the above line like :   Paremeter Set are: Header_name:Hdr_Name_1
                        LineVO1.setWhereClauseParam(0,Hdrval);
                        System.out.println("Inside MainAM invokeGO Method:"+LineVO1.getQuery());
                        < prints:Inside MainAM invokeGO Method:SELECT * FROM (select LINE_ID,hdr.HEADER_ID,LINE_NUMBER,LINE_NAME,Attach,hdr.header_name from xxtr_hdr hdr, xxtr_line line
    where hdr.header_id=line.header_id) QRSLT  WHERE (Header_name = :1)>
                        LineVO1.executeQuery();
    The issue is in the SQL build. I guess after setting the where clause, it should appear like :
    QRSLT  WHERE (Header_name = "Hdr_Name_1"
    Thanks

    Hu Sumit,
    I am doing that:
    LineVO1.setWhereClauseParam(0,Hdrval);
    before executequery. I even hard coded
    LineVO1.setWhereClauseParam(0,"XXXX");
    but still it din't work. I guess I am missing something small. because I have done this thing a lot of times earlier and it had worked.

  • Problem while Exporting Table Data to Excel Sheet

    Hi All,
    Im getting problem while downloading the table data to Excel.
    Steps i was fallowed:
    1)created Context node with four attributs.
    2)created one attribut(resource) type:  com.sap.ide.webdynpro.uielementdefinitions.Resource
    3)Taken one Filedownload UI and Property resource bounded to (resource)
    4)Added required jar file in the library and copied the same jar file in the navigator lib file
    written the necessary coding but showing the below  problem in the Browser
    You must Flush before accessing the resource content
    Please give me any suggestion  on this
    Regards
    Polaka

    Hi
    Check this might help with Brian Fernandes comments.
    Flush?
    Regards
    Arun Jaiswal

  • Not able to export context data to excel in NWDS 7.1

    Hi all,
    We have a requirement wherein I need to export data from a local context node to an excel file. I am using jxl.jar for this purpose.
    I am using a FileDownload UI element to generate the excel. I am working with NWDS 7.1 EhP1.
    I am using the following code :
    public void excel_download( )
         IWDCachedWebResource cachedExcelResource = null;
         String fileName = "TestExcel.xls";
         File f = new File(fileName);
         WritableWorkbook workbook = Workbook.createWorkbook(f);
         FileInputStream excelCSVFile = new FileInputStream(f);
         cachedExcelResource =getCachedWebResource(excelCSVFile,fileName,WDWebResourceType.getWebResourceType("xls","application/ms-excel"));
         wdContext.currentContextElement().setResource(cachedExcelResource);
         workbook.close();
         f.delete();
    private IWDCachedWebResource getCachedWebResource(InputStream file, String name, WDWebResourceType type)
         IWDCachedWebResource cachedWebResource = null;
         if (file != null)
              cachedWebResource = WDWebResource.getWebResource(file, type);     
              cachedWebResource.setResourceName(name);               
         return cachedWebResource;
    When I try to download the data to excel I am getting the following error:
    you must flush before accessing the resource content
    But when I deploy the application using NWDS2004s it works perfectly.
    Can anyone shed some light on why this may be happening? Am I missing something? Has it got anything to do with the NWDS version?
    Thanks and Regards,
    Saurabh

    Hi Saurabh,
          The above code is deprecated :-
    Replace that with this piece of code -->
    File f = new File(fileName);
    WritableWorkbook workbook = Workbook.createWorkbook(f);
    FileInputStream excelCSVFile = new FileInputStream(f);
    IWDResource cachedExcelResource = WDResourceFactory.createCachedResource(excelCSVFile, "FileName.xls", WDWebResourceType.XLS, false);
    wdContext.currentContextElement().setResource(cachedExcelResource);
    cachedExcelResource.getUrl(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal());
    WDFileDownloadBehaviour --> Will determine how you would like to download your file.
    Hope this helps !!!
    Cheers,
    Brian.

Maybe you are looking for