openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <ppod...@apache.org>
Subject Re: NPE on ManyToOne while using insertable = false, updatable = false
Date Thu, 03 Jan 2008 05:23:40 GMT

Hello Gilberto,
  I agree that there can be valid reasons to model it the way you have
mentioned. But having two fields in Item that (implicitly) mean the same
thing (i.e. a reference to Prudto instance and an Integer field value which
is Prudto's primary key) is generally a risky choice. The application has to
maintain the integrity by always ensuring that they mean the same thing. For
example, coding error can assign values for the two fields in the same Item
instance that is not the primary key value and that can lead to
inconsistencies that can be hard to track. 
    
  I can also see why you are expecting the reference being non-null when you
have set the Integer field -- because from the mapping annotation one may
infer (though not always correctly -- because imagine a case where the
intention of the design is Item to have a Pruoto and a cdPrudto that are not
related).

  The bottomline seems to be someone somewhere has to tell the provider that
cdPrudto is the same as the primary key of prudto in an Item instance.
Otherwise, it is not obvious what logic will determine that they mean the
same thing.

  
-- 
View this message in context: http://www.nabble.com/NPE-on-ManyToOne-while-using-insertable-%3D-false%2C-updatable-%3D-false-tp14582403p14592052.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message