3 Replies Latest reply on May 26, 2008 3:25 AM by Swen Barth

    Many-to-one writes non-existing IDs to the DB occasionally

    Swen Barth Newbie

      Hello,

      I have encountered a strange problem.

      I'm using JBoss4.0.4GA with EJB3.

      I have a global ID scheme for all my "Entity" beans, the IDs are generated by a TableGenerator, and are Longs which start with 100.000 and count upwards.

      I have an instance of bean A with a many-to-one relationship to instances of bean B. Recently I got the follwing exception when loading an certain instance of A from the DB:

      javax.persistence.EntityNotFoundException: Unable to find {bean B} with id 87005


      Which is pefectly sane, because there is no bean B with this ID (I checked in the DB). But I also found in the DB that in the row for bean A, in the column where B's Id should be found, there was indeed the value '87005'. That ID can never have existed before, because as I said, they started with 100.000 and count upwards.
      Does anyone have an explanation for that behaviour? Why was this impossible ID ever written to the DB?
      It is not reproducable, I have many rows in the table for bean A where the relationship to B is just fine. This occured for only 6 of about 6000 beans of type A.