I have some EJBs with relations. The relations seem to work fine, but when I turn on cascade delete and remove the parent, I get the exception in the title. Why is JBoss even looking for primary key zero? JBoss designed the schema so that zero means no relation, so why is it now trying to look up that key?
JBoss version is 3.2.7. The key field is of type Long, and is not nullable in the database. Have I misconfigured something? Am I using integer keys wrong?
I can post lots more code, but I'm hoping this simple question will point to the answer. Thanks!
Found my own answer: Foreign keys need to be nullable. JBoss considers zero a valid primary key, while 'null' means 'no relation here'. So if the foreign key field is a Java long (little L), the default value will be zero, and will crash. If it's a Long (big L), the default value is null, and JBoss is happy.