I'm trying to track down the expected behaviour in a situation where, using Container Managed Persistence (1.0 rather than 2.0, though if anyone knows how 2.0 handles it, that information would be greatly appreciated too...), a primitive data type (in this case an int) is mapped to an integer value in a database where the column may contain a null field. I can't seem to find anything in the spec concerning this, and was wondering if there's anything set in stone for how this works (a reference would be great) or failing that, how the major EJB servers out there deal with it.
A quick test with JBoss shows that a NullPointerException is generated on ejbLoad() - presumably because it internally maps to an Integer then invokes intValue(). That seems like one sensible approach to handling it, but prone to giving unexpected errors. Another suggestion I've heard is that it should return some default value (0, for example) but this has the downside of sometimes accidentally overwriting null values in the DB with whatever your default value is, so probably doesn't apply.
Can anyone shed some light on whether Sun defines expected behaviour in this case, and if not, why the JBoss system acts as it does?