Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] OneToOne Mappings not allowed on Aggregates?

OneToOne mappings are supported with aggregates, the issue is only with
allowNull.

The issue is that allowNull works by checking all of the field values in the
row, if they are all null, then null it used.  However, for a relationship,
it is not known if the value is null unless you query the relationship (and
even then a ToMany relationship may be empty), so there is not way to
reliably know if the value was null.

If you want the existing allowNull support, just set it back to true after
login/initialization.

Please log a bug for this, we should still support some level of allowNull
with relationships.  We should respect the users setting if they set
allowNull even with relationships, and probably have a third setting that
allowsNull but does not guarantee it comes back as null. 


Hector Ospina wrote:
> 
> Hi,
> We have been using Toplink for quite a few years and are in the process of
> migrating to EclipseLink 2.3.0
> 
> During our testing, we were surprised that EclipseLink does not support
> OneToOneMappings for aggregates, however Toplink does
> 
> On EclipseLink, the class AggregateObjectMapping resets the value for
> isNullAllowed on method initialize to false, whenever any of the dependent
> mapping is 
> 
> ...
>         // disallow null for aggregates with relationships
>         for (DatabaseMapping mapping:
> getReferenceDescriptor().getMappings()){
>             if (mapping.isForeignReferenceMapping() ||
> mapping.isAbstractCompositeDirectCollectionMapping()){
>                 isNullAllowed = false;
>             }
>         }
> ...
> 
> In this case OneToOneMapping extends from CollectionMapping, which is a
> "foreignReferenceMapping"
> 
> 
> Can anyone provide an explanation as to why and how to work around this?
> 
> 
> Thanks a lot,
> 
> 
> Hector Ospina
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/OneToOne-Mappings-not-allowed-on-Aggregates--tp32754669p32766337.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top