Primitive data type support in Cayenne

From: Andrei Adamchik (aadamchi..obox.com)
Date: Fri Apr 06 2001 - 10:10:00 EDT


It would be really cool to implement efficient primitive data types support
in Cayenne. From my previous experience and our conversations I know that
it is not an easy task. 2 main problems are:

A) How to distinguish between NULL and 0
B) How to store primitives in generic collections

The most dumb way of doing that is using an object instead of primitive
internally (say "java.lang.Integer" instead of "int"), and create methods
that convert it to int on the fly. We can easily do it like that, but I
think such implementation is as good as no support for primitives at all.

Another way I can think of is to provide real support for primitives only
for the attributes that are specified as NOT NULL in the model. This will
allow to use primitives in ObjectId's among other things (they are always
NOT NULL).

But even with this solution there is still a problem B) - generic
collections do not support primitive values. (Agian this is important for
ObjectId's among other things). Of course we can implement
java.util.Map-like class for int's ourselves, but then we will not be able
to insert normal objects in it. Do you think it is worth creating a class
that can hold both int and object maps internally and have 2 sets of
methods to insert and retrieve them? In a case when we know upfront that a
key "stringAttribute1" gives an Object value, and a key "intAttribute2"
gives an int value, we can probably hide two different collections under
the same "umbrella" collection object.

Any other ideas? Anyone heard of any good OpenSource int collection
implementations?

Andrei



This archive was generated by hypermail 2b30 : Sat Aug 04 2001 - 16:21:24 EDT