EntityManager.setFlushMode(COMMIT) Vs. Query.setFlushMode(COMMIT)

[P-331 of EJB3 In Action Book] states:
"By default, the database flush mode is set to AUTO. This means that the Entity-Manager performs a flush operation automatically as needed.
In general, this occurs at the end of a transaction for transaction-scoped EntityManagers and when the persistence context is closed for
     application-managed or extendedscope EntityManagers. In addition, if entities with pending changes are used in a query, the persistence
     provider will flush changes to the database before executing the query.If the flush mode is set to COMMIT, the persistence provider will
     only synchronize with the database when the transaction commits.However, you should be careful with this, as it will be your responsibility
     to synchronize entity state with the database before executing a query. If you don’t do this and an EntityManager query returns stale
     entities from the database, the application can wind up in an inconsistent state."
[P-353  EJB3 In Action Book] states:
"If the Query is set to FlushModeType.COMMIT, the effect of updates made to entities in the persistence context is not defined
     by the specification, and the actual behavior is implementation specific".
So setting the flush mode as COMMIT on EntityManager and Query have different results..Right ??

I would say try before you believe, but this is not the first time you post a blatant mistake/contradiction taken from this book, isn't it? Perhaps it is time to move on the a better, more dependable resource, or keep using this book and research a little further when you find something that seems backwards to you. I have personally recommended "Enterprise Javabeans 3.0" by O'Reilly many times before, and I still say it is one of the best resources on the subject right now.

Similar Messages

  • Application Module's "query-on-commit"  flag

    Hi All,
    Can you please guide how to set Application Module's "query-on-commit" flag as on/off.

    You'll want to create a method in your application module class that will expose your reporting functionality. You can do this by:
    1. Selecting your AppModule.
    2. Opening AppModuleImpl.java
    3. Creating a method to expose the necessary reporting services.
    4. You'll then need to make this method accessible by opening AppModule editor and clicking on "Client Interface". Shuttle your method to the "Selected" side.
    In the method you create in AppModule.java, pass the module (this) into your report class. You can then perform any actions you with such as querying VO's, updating, etc.
    Finally, for your view/controller layer you'll want to call the newly added methods in your AppModule class instead of calling your reporting classes directly. This will make your code cleaner and easier to maintain as well and also control (encapulate) the reporting services you want to expose to others.
    Hope that helps.

  • Re: Query before commit

    For my tests, I used the tutorial and didn't played with setIgnoreCache().
    And indeed, my newly created objects are part of the query. As per the
    code snipet, I create a new dog called "Medor". I add some code to print
    the value of setIgnoreCache too, to see what the default value is... The
    result of my creation+query without commit:
    SetIgnoreCache:false
    Dog Medor costs 80.0 dollars.
    Dog Medor Jr costs 90.0 dollars.
    Dog Binney costs 80.0 dollars.
    Dog Odie costs 30.0 dollars.
    Dog Rusty costs 25.0 dollars.
    Dog Fido costs 50.0 dollars.
    Dog Tasha costs 75.0 dollars.
    Dog Fluffy costs 35.0 dollars.
    Cheers,
    Patrick Guillot
    Versant France S.A.

    thanks . i have an idea.
    first ,create a row ,and then insert this row.

  • Executing subroutine after commit work, not on commit work

    Hi All,
    I want to execute my sub-routine after commit work, not on commit work.
    If any one have answer please mail me at  [email protected]

    Not sure if this helps you but this event is fired, when commit work is fired.
    Christian
    report test.
    class lcl_event_handler definition.
    public section.
        class-methods: on_commit_finished
             for event COMMIT_FINISHED
               of CL_OS_TRANSACTION_END_NOTIFIER.
    endclass.
    set handler lcl_event_handler=>on_commit_finished.
    commit work.
    class lcl_event_handler implementation.
    method on_commit_finished.
      break-point.
    endmethod.
    endclass.
    But check also oss note 704577

  • Serait il possible d avoir le choix entre deux presentations de clavier numerique  soit comme une calculette et comme il est presentement

    serait il possible d avoir le choix entre deux presentations de clavier numerique soit comme une calculette et comme il est presentement

    Bonjour Loic,
    Je te remercie pour ta réponse. Je réponds moi aussi un peu tardivement, ayant quelque peu laissé le problème de côté en attendant de trouver une solution. Mais merci pour ton retour.
    Ton approche est en effet très intéressante, je n'avais pas du tout pensé à aborder le problème sous cet angle !
    En revanche, j'ai du mal à imaginer comment retravailler ma base de données de façon à ce qu'elle entre dans le cadre de ce que tu proposes.
    Actuellement, pour résumer, ma base est grossièrement organisée de la sorte :
    Produit
    P2O5
    N
    Zn
    CaO
    Mgo
    Produit 1
    23
    3,2
    1,2
    Produit 2
    4,3
    2,2
    Produit 3
    26
    Chaque colonne correspond donc à une balise XML, et mon code XML donne donc par exemple ceci :
    <BLOC>
         <Produit>
                   <NomProduit>Produit 1</NomProduit>
                 <P2O>23</P2O5>
                 <Zn>3,2</Zn>
              <CaO>,2,2</CaO>
         </Produit>
          <Produit>
                   <NomProduit>Produit 2</NomProduit>
                 <N>4,3</N>
                 <MgO>2,2</MgO>
         </Produit>
          <Produit>
                   <NomProduit>Produit 3</NomProduit>
                 <N>26</N>
        </Produit>
    </BLOC>
    Comment retravailler ma base, de façon à ce que les différentes valeurs <quantité> correspondent aux bon termes <elements> pour chaque produit, et comment inclure différentes valeurs <quantité> et <element> pour un seul et même produit dans ma base ?
    J'ai du mal à visionner comment réaliser cela..!
    Je te remercie d'avance pour ta réponse,
    Fabien

  • Query a comma delimited list

    Suppliers is a field containing a comma delimited list of
    Supplier ID's.
    When a supplier logs in they should be able to view all the
    auctions that they have been registered for
    i.e if their supplierID is in the suppliers field.
    have tried this and get an error:
    <CFQUERY NAME="GetAuctions"
    DATASOURCE="#Application.Datasource#">
    SELECT * FROM Auctions
    WHERE '#Session.SupplierID#' IN 'Auctions.Suppliers'
    </CFQUERY>
    have tried this and recordcount is 0 when it should be 3:
    <CFQUERY NAME="GetAuctions"
    DATASOURCE="#Application.Datasource#">
    SELECT * FROM Auctions
    WHERE '#Session.SupplierID#' LIKE 'Auctions.Suppliers'
    </CFQUERY>

    You should avoid having a list value in a field and normalise
    your table. But if you want to stick with your style(which is not
    advisable), maybe you can do this. I believe your supplier id is a
    string so the code below may cause slowness in your system:
    <CFQUERY NAME="GetAuctions1"
    DATASOURCE="#Application.Datasource#">
    SELECT Suppliers FROM Auctions
    </CFQUERY>
    <cfoutput query="GetAuctions1">
    <CFQUERY NAME="GetAuctions2"
    DATASOURCE="#Application.Datasource#">
    SELECT * FROM Auctions
    WHERE '#Session.SupplierID#' IN(<cfqueryparam
    values="#Suppliers#" cfsqltype="CF_SQL_VARCHAR" list="Yes">)
    </CFQUERY>
    </cfoutput>
    But if your supplier id is a numeric value. then you can do
    this:
    <CFQUERY NAME="GetAuctions"
    DATASOURCE="#Application.Datasource#">
    SELECT A1.* FROM Auctions A1
    WHERE #Session.SupplierID# IN(SELECT A2.Suppliers FROM
    Auctions A2 WHERE A2.your_primary_key_for_table_Auctions =
    A1.your_primary_key_for_table_Auctions)
    </CFQUERY>

  • Commit timeout query - JDBC

    Ours is a java based front-ending application. In this, we are using oracle 11g JDBC driver to connect to ORACLE. As per JDBC specification, we are using query timeout parameter to specify the maximum threshold time a thread can be kept waiting for query to finish. But the same is available at query execution level only i.e. on statement object or on preparedstatement object. But we need similar functionality at connection level. To be more precise, any call to ORACLE from JDBC should not take more time than specified limit, otherwise the same calls should be cancelled. E.g. if commit is taking very high time and we don’t want our thread to be kept waiting for commit. In this case, probably on encountering timeout, we may either rollback the transaction or just close the connection,
    Is the same is supported anyhow in JDBC or in ORACLE which can be configured from front-ending application?

    There is a JDBC forum which is more appropriate for this.
    And IMHO a commit call is something that you do NOT want to control a timeout on.  Maybe in gross limits but not small limits.  If I had a commit that was in fact normally taking a long amount of time I would look to the statements being executed in the transactions as being incorrect or too big.  And refactor there.

  • How to query the comma seperated values stored in Database

    Hi,
    I have a strange scenario, I am storing the specific data as a comma seperated value in the database. I want to query the DB with the comma seperated value as a Bind variable against the comma seperated value stored in DB.
    For eg : The data stored in DB has
    Row1 - > 1,2,3,4,5,6,7,8
    Row2 - > 4,5,6,7,8,9,10
    When I pas the Bind variable as '4,8' I should get Row1 and Row2 .
    Quick help his highly appreciated.. Thanks in Advance

    Oh, and if you actually wanted the data returned rather than just the row primary keys....
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 1 as rw, '1,2,3,4,5,6,7,8' as txt from dual union all
      2             select 2, '4,5,6,7,8,9,10' from dual union all
      3             select 3, '1,6,7,9' from dual)
      4  -- end of test data
      5      ,r as (select '4,8' as req from dual)
      6  -- end of required data
      7      ,split_t as (select rw, regexp_substr(txt, '[^,]+', 1, rn) as val
      8                   from t, (select rownum rn from dual connect by rownum <= (select max(length(regexp_replace(t.txt, '[^,]'))+1) from t))
      9                   where regexp_substr(txt, '[^,]+', 1, rn) is not null
    10                  )
    11      ,split_r as (select regexp_substr(req, '[^,]+', 1, rownum) as val
    12                   from r
    13                   connect by rownum <= length(regexp_replace(req, '[^,]'))+1
    14                  )
    15  --
    16  select distinct t.rw, t.txt
    17  from   split_t st join split_r sr on (st.val = sr.val)
    18                    join t on (t.rw = st.rw)
    19* order by 1
    SQL> /
            RW TXT
             1 1,2,3,4,5,6,7,8
             2 4,5,6,7,8,9,10
    SQL>

  • Remove comma in query output from Char used as KF

    Hello Friends,
    To be able to display a characteristic in a particular way I used formula variable and displayed it as Key Figure in the query output. By doing this I am getting the output in the required format, but only problem is that the value is being displayed with commas. As it is an order number, I want to display it without commas.
    I don't want to use VB as the query is to be published in web also.
    Please suggest if there is any way to achieve this.
    Thanks in advance.
    Praveen

    Hey Praveen, there's a few ways to skin this cat. The simplest method is to make sure that the user parameters in SU3 don't have commas for numbers. The problem is that this is a global setting so you won't get commas for other numbers in which you may want commas. Also, you'd have to make sure your replacement variable was defined as type "number". The other options include using VBA in BEx, and/or Table Interface in the Web. If you are using BW 3.5, you can use XSLT to render a table with and not have commas for that value by using the XML Query Result Set Item. Hope that helps,
    Prakash

  • Why does JDBC make me commit a query?

    I was working with two DB2 database connections, A and B, and performed the following logic:
    Turned off AutoCommit for A and B
    Updated A
    Updated B
    Committted A
    Rolled back B
    Selected from A
    Selected from B
    Updated A
    Committed A
    Closed Connection A
    Closed Connection B
    Everything worked well until I tried to close Connection B. It threw a SQL Exception with the description "invalid transaction state". I read online that this means you are trying to close a connection with uncommitted data. It didn't make sense because the only thing I had done since rolling back was SELECT. When I tried it with a rollback or commit immediately before closing the connection, it worked. Any ideas why it would make me commit a SELECT? Is this just an unintended bug or could they have implemented it like this on purpose?

    I also first was wondering why a select should be committed.
    But also a select can cause locks that influence other connections. How, depends on the isolation level you set. For example SERIALIZABLE would block inserts by another connection that would change your retrieval in case you repeat it.
    To make the DBMS know that after your retrieval your processing of these data is done - no changes following - you must end the transaction by commit (or rollback - would be the same here since you've done no changes).

  • Need help with complex query with comma seperated

    Oracle version - 11.1.0.7.0
    Consider there are two tables table1 and table2
    Key---- ID
    A ---- 1
    A ---- 2
    A---- 3
    B ---- 4
    B ---- 5
    C ---- 6
    C ---- 8
    C ---- 9
    C ---- 10
    D ---- 11
    D ---- 12
    Table2
    ID
    1
    2
    6
    8
    11
    12
    I need result as in usedID column I should get comma seperated list of ID which are in table1 and table2 and in NOTUSEDID comma seperated list of ID which are in table1 but not in table2
    Key---- USEDID---- NOTUSEDID
    A ---- 1,2 ---- 3
    B ---- null ---- 4,5
    C ---- 6,8 ---- 9,10
    D ---- 11,12 ---- null

    Hi!
    Solution for Oracle 11g:
    SELECT A.KEY,
           listagg(decode(b.id, null, null, a.id), ',') WITHIN GROUP (ORDER BY  A.ID) AS USEDID,
           listagg(decode(b.id, null, a.id), ',') WITHIN GROUP (ORDER BY  A.ID) AS NOTUSEDID
      FROM TABLE1 A
           LEFT OUTER JOIN table2 b
           ON (A.ID = b.ID)
    GROUP BY a.key;
    Solution for databases prior to Oracle 11g:
    Please note that the function wm_concat is undocumented and can't be sorted!
    SELECT A.KEY,
           wm_concat(decode(b.id, null, null, a.id)) AS USEDID,
           wm_concat(decode(b.id, null, a.id)) AS NOTUSEDID
      FROM TABLE1 A
           LEFT OUTER JOIN table2 b
           ON (A.ID = b.ID)
    GROUP BY A.KEY;I used the following test case:
    create table table1(key varchar2(255), id number);
    CREATE TABLE table2(ID NUMBER);
    insert into table1 values('A', 1);
    INSERT INTO table1 VALUES('A', 2);
    INSERT INTO table1 values('A', 3);
    INSERT INTO table1 VALUES('B', 4);
    INSERT INTO table1 VALUES('B', 5);
    INSERT INTO table1 VALUES('C', 6);
    INSERT INTO table1 values('C', 8);
    INSERT INTO table1 VALUES('C', 9);
    INSERT INTO table1 VALUES('C', 10);
    INSERT INTO table1 values('D', 11);
    insert into table1 values('D', 12);
    insert into table2 values(1);
    insert into table2 values(2);
    insert into table2 values(6);
    insert into table2 values(8);
    insert into table2 values(11);
    insert into table2 values(12);
    commit;Best regards,
    Matt
    Edited by: Matt Schulz on Oct 12, 2011 12:43 PM

  • Comma seperated checkboxes - add comma AND a space

    Comma seperated checkboxes has worked great for me, except for one thing. I want the values to be seperated by a comma AND a space, like so:
    This is what I get now.
    location1,location2,location3
    What I'd like to get is:
    location1, location2, location3
    Is what I want possible? If so what's the easiest way to change it?
    -Kevin

    I'm running into another problem. Your solution for displaying the locations with spaces works great when querying a single record.
    However, when I use in a repeat region, all records show the location of the first record. This problem is only present in a repeat region.
    For the repeat region, I choose a recordset called feeds to repeat. Repeating elements inside are displayed as .
    Now, $locations is in that recordet but $locations_with_spaces is not.
    Is there a way to get $locations_with_spaces to repeat properly?
    Thanks
    -Kevin

  • Comm channel missing in comm channel monitoring

    Hi,
    I have created sender and receiver communication channels of adapter type XI. I am using PI 7.0 version. But I don't see these communication channels in RWB comm channel monitoring.
    I was going through the help.sap.com and in
    http://help.sap.com/saphelp_nw04s/helpdata/en/5c/22ee41c334c717e10000000a155106/frameset.htm
    In this it is mentioned clearly as "The XI adapter as part of the Adapter Engine gets the required....."
    if this is part of the adapter engine then it should show the communication channels registered for it.
    Moreover if SAP doesn't want to display these XI adapter  com channels then why they have XI adapter type in the drop down box to filter the data.
    Please provide your guidance in this regard.
    thanku
    bk

    Hi Bhargvi,
    XI adapter is in-built in the integration engine............in RWB in comm channel monitoring, you can view all the comm channels which are at adapter engine...................so this is why you cannot see your XI, IDOC or HTTP adpater in comm channel monitoring because these adapters reside in integration engine directly..................but to tell integration engine regarding the target system you have to configue thier comm channels in ID.
    Regards,
    Rajeev Gupta

  • How to COMMIT a table whithout commit other ones?

    I've locked 2 tables by FOR UPDATE NO WAIT, now I need the table_1 to be committed(and unlocked), leaving the table_2 uncommitted(locked). if I wrote COMMIT, both of the two tables will be committed.
    Can u help me?
    thanks!

    We can use the AUTONOMOUS TRANSACTION pragma to commit work independently of a larger wrapping transaction.
    Please make sure that is really what you want to do: if the larger transaction is rolled back will the committed state of table_1 conflict with the rolled-back state of table_2?
    Cheers, APC

  • Commas keep repeating (runaway commas?)

    On a relatively new 2012 27" iMac, fusion drive:
    While working in MS Word 2011, suddenly commas started repeating  themselves in a document at a very fast pace; when I shifted to other  applications, in search space, commas automatically appeared; also the  Mac symbol in the upper left corner became lighter
    I've restarted, shut down for a period of time but each time I start  again, the commas appear in whatever field I start with in whatever  application I utliize
    Any thoughts?

    Well, as far as I can see the obvious suggestion is something wrong with your keyboard.  Have you tried turning it upside down, cleaning it out, that type of thing?  Is it possible for you to connect your keyboard to another computer and see if the same thing happens?  I'm assuming your computer is set to login automatically, because it sounds like you are getting commas all the time in every active window.
    Hope that helps.
    Ivan

Maybe you are looking for

  • Halo: Combat Evolved EAX Windows 7 64 bit working!

    I used the newest version of Alchemy and Halo .05, with Windows 7 64 bit. The settings that are provided for 32 bit vista work as well in Windows 7. If you run 64 bit Windows 7 or Vista here is the new key: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mic

  • Airport internet connection problems in OS X but not in XP or iBook

    I have an iBook and an iMac, and the iMac has Leopard and XP on it. When in Leopard, most of the time, the internet connection is extremely slow and can never load a full page in Safari, always quitting halfway or the connection drops completely. Whe

  • What's this error mean

    [2.2.4] WIF KB Versions does not agree with current KB Version 3.05. WS KNOX6860 will not be loaded I just loaded Zen 7 SP1 IR14 and hoping to fix it and its still happening.

  • HT203216 Can you remove contacts from an ipod updated with iTunes 11 software?

    Does anyone know how you can remove all contacts from an iPod under the new iTunes 11 software?  We sync to one family account and the kids don't want my contacts - how can you delete them?  We can't find the area to select to eliminate the sync of t

  • Getting problem with realms

    Hi Guy's I created realm and i assign that realm at user level. But it is not reflecting.. Any other set up i have to do?. The same stuff i applied at responsibility level. It is working.. If anyone knows reply Thanks & Regards Palakondaiah.U