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.

Similar Messages

  • Could i display data in VO before commit and re-query?

    I have inserted some rows into ViewObject.i will display these rows before commit them.
    The vo will be a temporary table.
    how can i do it ? thanks ,best regards.

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

  • 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.

  • Select the Key Figures to be presented in a query before execute the it

    Hi,
    I want to select(through checkbox) the Key Figures to be presented in a query before executing the query. I'm creating BEX queries and web templates (I'm working on BEX 7.0).
    I haven't found clear post about this so if you have implemented something like this please help me and share your solution.
    Kind regards,
    Ana

    Hi,
    If you set a property of your KF as "Hide and can be shown", you will get a filter option for these KFs after executing the report in the navigational block of web report.
    When you click on that filter, you will get the list of KFs, then you can select the desired KFs using check box.
    Regards,
    Yogesh.

  • Trying to set the entity attributes in before commit and get the following

    i get the following error when i try to set the entity attributes before commit.
    JBO-28202: Entities invalidated in beforeCommit(). Need to re-validate and post.
    can somebody let me know, how to re-validate and post.

    I Suggest you set its Attribute on EOImpl, override doDML, and before call super.doDML set your Attribute. There is a special reason to set Attribute on beforeCommit?
    Best Regards

  • Before commit

    when does the before commit operation in ViewObjectImpl will invoke in ADF...Any one can give a sample code for using the same for inserting a value for a field in the ViewObject which is not displayed in JSP page
    kindly Reply
    Regards
    Anitha

    Use this forum to report broken links or general feedback about Oracle documentation. This forum is not monitored > by Oracle support or product teams and so Oracle product and technology related questions will not be answered. http://forums.oracle.com/forums/category.jspa?categoryID=19

  • Encrypt value before commit

    Hello,
    I'm using Oracle JDeveloper 11g Release 2 (11.1.2.3.0).
    I have a form that the user must enter some values, one of these values is a password. I need to pick up that value before commit and encrypt it. Actually the password is stored in the database without encyptation, just as the user entered it.
    My application does not use adf security, and now it's too late to change everything.
    Any idea that how  can I fix this?
    Thanks in advance!

    Hello Shay!
    Thanks a lot for your answer, I'm newby in ADF and I don't know how to do that. I think that the easiest option is to overwrite the doDML method.
    I overwrite this method in the EOImpl and, now I have this:
         * Custom DML update/insert/delete logic here.
         * @param operation the operation type
         * @param e the transaction event
        protected void doDML(int operation, TransactionEvent e) {
            super.doDML(operation, e);
    I have a method called encrypt(password), that return the password encrypted.
    How can I set the new string to the password attribute when I update on database? I guess I have to insert this code before super.doDML(operation e);, is it?
      if (operation == this.DML_UPDATE){
                // CODE HERE
    Please can you help me with this? Thanks in advance!

  • Size of SQL query before execution and after execution

    hi all
    I need help on how can i find out the size of SQL query before execution and after execution in java
    The query can be any query select / insert / update
    Can anyone help me if any system tables help to find out the required size i mentioned
    Urgent help is required
    Thanking in advance

    I need the size in terms of bytes
    like the rquirement is stated as below
    select ................: 10 B , return 250 B
    so i need size before and after execution in terms of bytes

  • Test Query before executing

    Hello everyone,
    I am write my final exam and I have to use oracle as the database and php as the GUI - programming - language.
    Image this situation:
    - Webform with 3 Textfields (names are a,b,c)
    I have a table let's say mydata
    mydata | value1 | value2 | value3
    And I have defined some integrities like
    value1.length >= 5
    value2.length <= 5
    value3.length >= 5 and value3.length <= 10
    Now I want as soon sobody presses the submit button at the formular, the input-data should be checked. Right now I check them with PHP and as soon as an error occure, I return to the form with some error message.
    I know, that is not the correct way, because if I check the data with PHP I don't need to create integrities at oracle.
    Is there a way to check a query before exceuting? PHP creates three
    querys, tests them all, and as soon there are no errors, then php calls the final
    exceute querys.
    My english is really bad, hopefully you get what I mean.
    Thanks a lot
    Hauke
    PS.: I know I could update / insert all three values at the same time and it won't update / insert anything if one error occures, but in my program a form inserts / updates data from different tables at the same time
    Message was edited by:
    user584520

    Hey,
    so basicly what I what to do is to iterate through an array with sql - statements.
    ---- PHP ARRAY ----
    update table1 set x=21 where id=1;
    update table2 set y=333 where id=2;
    ---- PHP ARRAY ----
    Now, I want to make sure, that all statements are correct for the oracle intergrity BEFORE the data will update.
    In other words, all the querys should be tested and only if all tests are correct, then
    it sould do the update - commands.
    In case it's still not clear lets say you have a webform for changing your personal data. One field for your email-address and one for you lastname. I have oracle constraints to validate the email-address and another for validate the length of lastname. Also lets consider the email-address and lastname are not in the same table. What I have to do is something like
    update CONTACTS set email='test' where id=1;
    and
    update ADDRESS set lastname='somebody' where id=1;
    If I put both querys in one array and iterate thought it, the first element will cause an error because of the violation of constraints for email-address, the second one will be fine. So after iterating thought the array the lastname has changed, but the email is still the old one.
    So the only way is the check all statements before executing them, but I have no idea if there is a possibility to do something like that.
    Thanks again ;-)
    Hauke

  • How check value befor commit my form

    hi master
    sir
    how check value befor commit my form if that value right than commit otherwise show message box and not save
    please give me idea
    thanking you
    aamir

    Have you not tried using When-Validate-Item Trigger.
    Like if i have an Item Which can only take dates between sysdate and sysdate-3 your code in when-validate of the item should be
    If :BlockName.ItemName NOT BETWEEN SYSDATE-3 AND SYSDATE THEN
    MESSAGE('Pleaes Enter valid date);
    RAISE FORM_TRIGGER_FAILURE;
    END IF;
    This will fire, and commit will fail.

  • DBWn and LGWR work before commit

    " - Oracle has generated redo log entries in the redo log buffer of the SGA. The redo log record contains the change to the data block and the change to the rollback
    block. These changes may go to disk before a transaction is committed.
    - The changes have been made to the database buffers of the SGA. These changes may go to disk before a transaction is committed."
    (c) Concepts 10g R.2
    When this situation (write dirty blocks and redo entries befor commit) occurs? It is importantly for me to refer on official documentation, when this situations occurs.
    Thanks,
    Best Regards

    915968 wrote:
    " - Oracle has generated redo log entries in the redo log buffer of the SGA. The redo log record contains the change to the data block and the change to the rollback
    block. These changes may go to disk before a transaction is committed.
    - The changes have been made to the database buffers of the SGA. These changes may go to disk before a transaction is committed."
    (c) Concepts 10g R.2
    When this situation (write dirty blocks and redo entries befor commit) occurs? It is importantly for me to refer on official documentation, when this situations occurs.
    no

  • Weird result of oracle query before and after function base index creation

    Hi All,
    Here is the unique situation we are facing after creating just an index.
    The query result before the index and the query result after the index do not match.
    This is very illogical situation. Shidhar and me have done lot of R&D, also tried to get lots info from Google but we couldn't decipher the reason for that.
    I am giving you all the details about the query, index and tables with following steps.
    Please let us know if anything is going wrong from our side or is it a bug at oracle level which is a rarest possibility but a possibility.
    Step 1 :- Create table
    create table TEMP_COMP
    ID VARCHAR2(10),
    GROUP_ID VARCHAR2(10),
    TRAN_DATE DATE,
    AMT_1 NUMBER,
    AMT_2 NUMBER,
    AMT_3 NUMBER
    Step 2 :- Insert Sample data
    set feedback off
    set define off
    prompt Deleting TEMP_COMP...
    delete from TEMP_COMP;
    commit;
    prompt Loading TEMP_COMP...
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('01', 'G01', to_date('01-03-2007', 'dd-mm-yyyy'), 1, 11, 111);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('02', 'G01', to_date('02-03-2007', 'dd-mm-yyyy'), 2, 22, 222);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('03', 'G01', to_date('03-03-2007', 'dd-mm-yyyy'), 3, 33, 333);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('04', 'G01', to_date('04-03-2007', 'dd-mm-yyyy'), 4, 44, 444);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('05', 'G01', to_date('05-03-2007', 'dd-mm-yyyy'), 5, 55, 555);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('06', 'G01', to_date('01-03-2008', 'dd-mm-yyyy'), 6, 66, 666);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('07', 'G01', to_date('02-03-2008', 'dd-mm-yyyy'), 7, 77, 777);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('08', 'G01', to_date('03-03-2008', 'dd-mm-yyyy'), 8, 88, 888);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('09', 'G01', to_date('04-03-2008', 'dd-mm-yyyy'), 9, 99, 999);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('10', 'G01', to_date('05-03-2008', 'dd-mm-yyyy'), 10, 100, 1000);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('01', 'G01', to_date('01-03-2007', 'dd-mm-yyyy'), 1, 11, 111);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('02', 'G01', to_date('02-03-2007', 'dd-mm-yyyy'), 2, 22, 222);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('03', 'G01', to_date('03-03-2007', 'dd-mm-yyyy'), 3, 33, 333);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('04', 'G01', to_date('04-03-2007', 'dd-mm-yyyy'), 4, 44, 444);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('05', 'G01', to_date('05-03-2007', 'dd-mm-yyyy'), 5, 55, 555);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('06', 'G01', to_date('01-03-2008', 'dd-mm-yyyy'), 6, 66, 666);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('07', 'G01', to_date('02-03-2008', 'dd-mm-yyyy'), 7, 77, 777);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('08', 'G01', to_date('03-03-2008', 'dd-mm-yyyy'), 8, 88, 888);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('09', 'G01', to_date('04-03-2008', 'dd-mm-yyyy'), 9, 99, 999);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('10', 'G01', to_date('05-03-2008', 'dd-mm-yyyy'), 10, 100, 1000);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('01', 'G02', to_date('01-03-2007', 'dd-mm-yyyy'), 1, 11, 111);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('02', 'G02', to_date('02-03-2007', 'dd-mm-yyyy'), 2, 22, 222);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('03', 'G02', to_date('03-03-2007', 'dd-mm-yyyy'), 3, 33, 333);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('04', 'G02', to_date('04-03-2007', 'dd-mm-yyyy'), 4, 44, 444);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('05', 'G02', to_date('05-03-2007', 'dd-mm-yyyy'), 5, 55, 555);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('06', 'G02', to_date('01-03-2008', 'dd-mm-yyyy'), 6, 66, 666);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('07', 'G02', to_date('02-03-2008', 'dd-mm-yyyy'), 7, 77, 777);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('08', 'G02', to_date('03-03-2008', 'dd-mm-yyyy'), 8, 88, 888);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('09', 'G02', to_date('04-03-2008', 'dd-mm-yyyy'), 9, 99, 999);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('10', 'G02', to_date('05-03-2008', 'dd-mm-yyyy'), 10, 100, 1000);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('01', 'G03', to_date('01-03-2007', 'dd-mm-yyyy'), 1, 11, 111);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('02', 'G03', to_date('02-03-2007', 'dd-mm-yyyy'), 2, 22, 222);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('03', 'G03', to_date('03-03-2007', 'dd-mm-yyyy'), 3, 33, 333);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('04', 'G03', to_date('04-03-2007', 'dd-mm-yyyy'), 4, 44, 444);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('05', 'G03', to_date('05-03-2007', 'dd-mm-yyyy'), 5, 55, 555);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('06', 'G03', to_date('01-03-2008', 'dd-mm-yyyy'), 6, 66, 666);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('07', 'G03', to_date('02-03-2008', 'dd-mm-yyyy'), 7, 77, 777);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('08', 'G03', to_date('03-03-2008', 'dd-mm-yyyy'), 8, 88, 888);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('09', 'G03', to_date('04-03-2008', 'dd-mm-yyyy'), 9, 99, 999);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('10', 'G03', to_date('05-03-2008', 'dd-mm-yyyy'), 10, 100, 1000);
    insert into TEMP_COMP (ID, GROUP_ID, TRAN_DATE, AMT_1, AMT_2, AMT_3)
    values ('11', 'G01', to_date('03-03-2008', 'dd-mm-yyyy'), 100, 200, 300);
    commit;
    prompt 41 records loaded
    set feedback on
    set define on
    prompt Done.
    Step 3 :- Execute the query.
    SELECT GROUP_ID
    , SUM(LAST_YR_REV) as "Year_2007_Amt"
    , SUM(CURR_YR_REV) as "Year_2008_Amt"
    FROM (
    SELECT GROUP_ID,
    CASE WHEN TO_CHAR(TRAN_DATE,'YYYYMM') BETWEEN'200701'AND'200712'THEN SUM(AMT_1) ELSE 0 END AS LAST_YR_REV ,
    CASE WHEN TO_CHAR(TRAN_DATE,'YYYYMM') BETWEEN'200801'AND'200812'THEN SUM(AMT_1) ELSE 0 END AS CURR_YR_REV
    FROM TEMP_COMP t
    WHERE GROUP_ID ='G01'
    AND TO_CHAR(TRAN_DATE,'YYYYMM') BETWEEN'200601'AND'200912'
    GROUP BY GROUP_ID, TRAN_DATE
    GROUP BY GROUP_ID
    The result of above query
    GROUP_ID Year_2007_Amt Year_2008_Amt
    G01 30 180
    Step 4 : Create composite index
    create index GROUP_ID_TRAN_DATE_IDX on TEMP_COMP (GROUP_ID, TO_CHAR(TRAN_DATE,'YYYYMM'))
    Step 5 : Execute once again query from step 3.
    SELECT GROUP_ID
    , SUM(LAST_YR_REV) as "Year_2007_Amt"
    , SUM(CURR_YR_REV) as "Year_2008_Amt"
    FROM (
    SELECT GROUP_ID,
    CASE WHEN TO_CHAR(TRAN_DATE,'YYYYMM') BETWEEN'200701'AND'200712'THEN SUM(AMT_1) ELSE 0 END AS LAST_YR_REV ,
    CASE WHEN TO_CHAR(TRAN_DATE,'YYYYMM') BETWEEN'200801'AND'200812'THEN SUM(AMT_1) ELSE 0 END AS CURR_YR_REV
    FROM TEMP_COMP t
    WHERE GROUP_ID ='G01'
    AND TO_CHAR(TRAN_DATE,'YYYYMM') BETWEEN'200601'AND'200912'
    GROUP BY GROUP_ID, TRAN_DATE
    GROUP BY GROUP_ID
    The result of above query
    GROUP_ID Year_2007_Amt Year_2008_Amt
    G01 0 210
    Thanks
    Sunil

    I just wanted to make a comment. The predicates in both your queries are flawed I believe. You convert a date column to a character and then you say only pick the converted result between two sets of characters.
    TO_CHAR(TRAN_DATE,'YYYYMM') BETWEEN'200601'AND'200912'It should be coded like this for a proper date range comparison:
    TRAN_DATE BETWEEN TO_DATE('200601','YYYYMM') AND TO_DATE('200912','YYYYMM')That will eliminate the need for you to create FBI that you created. You should now be able to create a regular (B*Tree) index on the TRAN_DATE column.
    Also, now that we have the structure of your tables and sample data, what business question are you trying to answer? I think there is a better query that can be written if we know the requirements.
    Hope this helps!

  • "0" doesn't display before comma in float numbers...

    Hi fellow APEX users,
    Have you ever experienced this issue with float numbers in your APEX forms?
    When I type float numbers between -1 and 1 in forms (e.g. 0,7 or -0,2), and after having submitted the form then reloaded it for editing, "0" doesn't display before the comma.
    For example I got:
    *,7* instead of *0,7*
    -,2 instead of -0,2
    etc.
    If I look in SQL Workshop, I see the same (no "0") but I'm pretty sure that the value is properly recorded in the database.
    The thing is that it's not very nice for the end users, as they can think the value is wrong.
    Does anybody have a solution to display proper float numbers with "0" in the forms?
    For info I use the NUMBER type.
    Any help much appreciated!
    Thanks,
    Romain.
    Edited by: romain.apex on Feb 5, 2012 8:30 PM

    Hi Peter!
    Of what type is your item? Display as text or do you use the item value for further computations.
    If it is only for means of displaying the correctly formatted number, I'd change the item source to a query and would equip the desired column with a to_char function like:
    select to_char(str_be_main, 'fm999G999G990D00') from yourtable where ...You could also use a post calculation computation and enforce the format there:
    to_char(:P2027_YOUR_ITEM,'fm999G999G990D00')Maybe this helps!
    Brgds,
    Seb
    Edited by: skahlert on 11.02.2011 07:53

  • Unable to read changes before commit

    I have a mix of insert and select statements for a particular transaction operation.
    I need to insert to table 1 a set of five records. ie. five inserts to table 1.
    Then i need to sum up a column in table 1, this may have certain records which were inserted recently and some might be older ones.
    This sum needs to be inserted into another table 2.
    In my code i maintain the sequence of inserting, fetching the sum and inserting. I confirm the sequence by giving System.out.println().
    But since everything runs inside a container managed external transaction controller.
    Even though i see the System.out.println's in proper sequence, the suming query is happening before.
    At the end, i have Before JTS completion, followed by my insert sqls, followed by After JTS completion.
    Clearly the problem is, the fetch is happening before i insert, in JTS.
    So how do i make sure, that the fetch happens after my first insert.

    I assume that you are using the TopLink UnitOfWork. The UnitOfWork defers committing all changes to the database until the commit (beforeCompletion in JTA), so any queries you perform will not see any of these changes until after the commit. It does this to optimize the commit, maintain referential integrity, avoid deadlocks, avoid holding pooled connections, etc.
    You must either:
    - perform the inserts and the sum query in two separate transactions
    - compute the sum from the objects in memory
    - use a database session and insertObject instead of a unit of work
    To compute the sum in memory you may wish to use a conforming query in TopLink to query the new objects that have not yet been inserted to the database.
    In the 10.1.3 release, there will be support for a non-deferred unit of work, and a writeChanges() unit of work API to write changes before the commit.

  • 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.

Maybe you are looking for