Hi Dain, On Dec 12, 2006, at 2:33 PM, Dain Sundstrom wrote:
On Dec 12, 2006, at 1:45 PM, Craig L Russell wrote:There's nothing that I can find in the JPA specification about preserving null vs. empty Collections and Maps. There's no good (practical) way to implement null values for these types in relational databases, which is the target of the specification.The only way I know to do it is to redundantly add a column to the table whose mapped class contains the Collection or Map field that knows whether an empty Collection or Map should be presented to the user as null. This was deemed by the JPA experts to be non- trivial and non-demanded by users.I am curious why this issue came up while trying to implement CMP 2 via JPA.CMP2 requires that collection valued fields always be non-null (i.e., you always get an empty collection). I wanted to know what guarantees JPA provided in terms of the field being not null. Specifically, if the field is set to null when an empty collection is loaded, I would have to compensate for that in my framework code. Since, JPA does the intelligent thing and inserts an empty collection, my job is easier.
Yup. All you really need to do is to instantiate an empty collection in the constructor and you're home free.
Craig Russell Architect, Sun Java Enterprise System http://java.sun.com/products/jdo 408 276-5638 mailto:[EMAIL PROTECTED] P.S. A good JDO? O, Gasp!
Description: S/MIME cryptographic signature