ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Huy <huym...@swiftdsl.com.au>
Subject Re: A question about nullValue in resultMap.
Date Sat, 05 Feb 2005 06:23:51 GMT
Clinton Begin wrote:
>>I've never liked to use Integer. Is it really the 
>>better design choice ? and why ? Is it the
> Not for all situations.  But the simple fact is that a primitive
> cannot represent NULL state without using a "magic number".  Magic
> numbers are (to the best of my experience and education) NEVER a good
> idea.  Hence, you're better off with an Integer than a "magic int".

I have to admit I was always of the opposite view. I hated nulls with a 
vengeance when it came to database data. I also don't like magic numbers 
unless they had meaning in the given domain. Most of the time (95%) zero 
made perfect senses hence I always defaulted my database columns to zero 
(never -1 or anything like that). In cases where I needed to know the 
difference between zero and null (which was rare) there were always 
other ways to represent this (eg. existence of a row etc.)

>>From a practical perspective, Integers are better because they are
> objects and can take part in Object features.  For example, you can
> use them in a collection or pass them as a parameter to your SQL Maps.
>  If you're lucky enough to use J2SE 5, then this is less
> important...but trust me, primitives are no less of a problem in J2SE
> 5.

This is a major problem I found with java; i.e not being able to use 
primitives in collections. I think either primitives is a real wart in 
java or collections is missing a real feature. That reminds me of a 
little annoyance with sqlmap where I always had to wrap my primitives in 
Integer, Boolean etc when passing it to the query, update methods.

>>From a purely academic sense, Java is a hybrid language.   A Smalltalk
> developer would tell you to avoid primitives like the plague.  A C
> developer, would tell you primitives are the only way to go. 
> Generally speaking, Java is more OO than not, so the Smalltalk
> developer would probably be correct more often than the C developer.
> All I can say is...dude, you'd love Ruby.  ;-)

I'm actually a python fan and i'm sure you know about the rivalry there 
;-) There are some nice features in  ruby though. But I think that 
activerecord (ruby on rails) thing they have doesn't come close to 
sqlmaps for major applications.



View raw message