Re: [Objectbridge-developers] optional relationships
Brought to you by:
thma
From: Dirk O. <di...@xa...> - 2001-08-13 17:01:05
|
Joel Cordonnier wrote: > > > 1) extend the mapping to let the user specify which > > value object he > > wants to have assigned for individual attributes. So > > there would be a > > <field.valueType/> in addition <field.name/> node in > > the mapping XML > > file. This would allow for e.g. Integer values to be > > passed. To make > > this work with reflection, JdbcAccess should use a > > set method if that's > > available (could be found out using reflection) > > ok ! And what bring this solution ? to assign a given > value, when you can the type ?? It's all about distinguishing a NULL value that comes from the database from an (int)0. The two *are* different and you have to make sure that your app can see which case is which. Using just int's you cannot distinguish. Using java.lang.Integer gets you further: int foo = 0; // is that NULL or really zero Integer foo = null; // this really means NULL Integer foo = new Integer(0); // this is the Integer value zero. > I think that the second solution (eg. implement the > interface) is better. Does anybody know what other O/R mapping frameworks do? I have some working knowledge with Apple's Enterprise Objects Framework, they call a method named unableToTakeNullForKey(String key) on the instance that's about to have a NULL value assigned. -dirk |