3 Replies Latest reply on May 12, 2005 6:31 AM by Stefano Gallina

    Get the right result after an insert with an entity CMP EJB

    Stefano Gallina Newbie

      Hi all,

      in my project i use Entity EJB to insert/update and remove data from the database.
      To collect dat i execute some SELECT query which use the Connection from a datasource.
      Well, in a specific situation i have, in the same mthod:

      - Insert some data

      - Get, using a SELECT query, some data plus the data i have just inserted

      Well, i noticed that if i execute the SELECT query i can't have the data i have just insereted using the Entity.
      Well, how can i fix this problem out ?
      I know that the Entity bean locks the table and doesn't see you the data before the end of the transaction.
      Is there anyway to get the data ?
      Do i have to change the transaction type of the EJB ?
      Cheers.

      Stefano



        • 1. Re: Get the right result after an insert with an entity CMP
          albert kam Newbie

          Hi friend,

          Yes, we have a similar problem here. We have switched from JBoss 3.0.8 to 3.2.6. Our application was working well using JBoss 3.0.8, where we use the connection from the datasource to query the inserted / updated / deleted CMP entity. The changes can be seen from the select statement issued within the same transaction.

          After porting to 3.2.6, it's behaviour has changed, however. The changes after insert can be seen in the select's result. But the changes updated rows can't be seen in the subsequent select result in the same transaction.

          Anyone has any idea what happens here ? Pleaseeeeeeeeeeee .... It could be the configuration or anything. Please help us ^-^

          Thanks,
          Albert Kam

          • 2. Re: Get the right result after an insert with an entity CMP
            Stefano Gallina Newbie

            Hello,

            i use JBoss 3.2.0 with Tomcat 4.1.24 and i can't see the changes after an insert and after an update.
            It is strange, i think that it depends on the Entity because to get data i use a simple SELECT i compose by my own.
            I call my entity form a method of a session EJB so everything is in the same transaction.
            I think that the entity locks the data until the end of the method of the session bean so when i execute the SELECT query the data i have just inserted are not shown because the transaction is not ended.
            I think that i could fix this problem out using the EJB QL , but this is not good for performance of the application because for each row it is created an instance of the EJB.
            My application has to be deployed on WebSphere so probably on this applicationserver i can get a different behaviour.
            Any other suggestion ?
            Cheers.

            Stefano





            • 3. Re: Get the right result after an insert with an entity CMP
              Stefano Gallina Newbie

              Hello,

              reading the message with the title : "Mixed JDBC and CMP access within a single session method".
              I cleared my mind about my doubts.
              Cheers.

              Stefano