Discussions

EJB programming & troubleshooting: Transaction and BMP ejbFind conflict

  1. Transaction and BMP ejbFind conflict (5 messages)

    Hi everyone,
    Something i'am worry about with my BMP (TX_REQUIRED demarcation), accessed by a transactional method (I'll write explicitly the transaction boudaries)
     Let's say we have BMP entity A, with LocalHomeInterface HA and LocalInterface LA

    {
    Transaction begin

    HA ha;
    LA la;

    la = <...> ha.ejbFindByPrimaryKey();

    la.set1();
    la.set2();

    Collection col = ha.findAll<...>();

    Transaction Rollback
    }


    In this case, I would expect thet set1() and set2() has no effect in database since the transaction rolled back, BUT since the ejbFind method causes the container to call ejbWrite , data have changed in the database !

    Isn't that a real problem ? Or I missed something ?


    Thanks




    Threaded Messages (5)

  2. Transaction and BMP ejbFind conflict[ Go to top ]


    Yes.. I missed that "Rollback" not only prevent data in cache to be written, but also ask DB ResourceManager to rollback ...

    Arnaud
    "Aide-toi, et le Ciel t'aidera"
  3. Transaction and BMP ejbFind conflict[ Go to top ]

    Remember that transactions are set on a per method level. Did you set the tx properties for every method of the entity bean?

    Dave Wolf
    Personified Technologies LLC
  4. Transaction and BMP ejbFind conflict[ Go to top ]

    Yes, but the question was theorical : "the data have changed" meant "the data would change when this piece of code will be executed", which is not true (i think) since the DBRM is able to rollback the SQL command triggered by ejbWrite()
  5. Transaction and BMP ejbFind conflict[ Go to top ]

    Please tell me how your ejbFind method caused a change in you database.
  6. Transaction and BMP ejbFind conflict[ Go to top ]

    ejb 2.0 spec says :
    "Before invoking the ejbFind<METHOD>(...) method,the container must therefore first synchronize the state of any entity bean instances that are participating in the same transaction context as is used to execute the ejbFind<METHOD>(...) by invoking the ejbStore() method on those entity bean instances."

    and in ejbStore() { (...) connection.prepareStatement("update ...") ...executeUpdate(); }