openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: Collection (or Map) relationships and null
Date Tue, 12 Dec 2006 21:45:40 GMT
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.


On Dec 11, 2006, at 3:00 PM, Abe White wrote:

> 1. Loaded instances last stored with a null or empty collection/map  
> are restored with an empty collection/map, period.  You can ignore  
> all the talk about null indicators.
> 2.  Instances you construct yourself will maintain their null vs.  
> empty field values at least until persist.  Beyond that you  
> shouldn't rely on null collections and maps remaining null -- they  
> might become empty.
> 3. Pinaki's tip shows how to tell OpenJPA to throw an exception if  
> you attempt to add an entity of the wrong type to a persistent  
> collection/map  
> field.________________________________________________________________ 
> _______
> Notice:  This email message, together with any attachments, may  
> contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and   
> affiliated
> entities,  that may be confidential,  proprietary,  copyrighted   
> and/or
> legally privileged, and is intended solely for the use of the  
> individual
> or entity named in this message. If you are not the intended  
> recipient,
> and have received this message in error, please immediately return  
> this
> by email and then delete it.

Craig Russell
Architect, Sun Java Enterprise System
408 276-5638
P.S. A good JDO? O, Gasp!

View raw message