[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Many-to-one writes non-existing IDs to the DB occasionally

swenbarth do-not-reply at jboss.com
Mon Jan 22 10:36:33 EST 2007


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.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4004853#4004853

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4004853



More information about the jboss-user mailing list