You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Clute, Andrew" <An...@osn.state.oh.us> on 2004/02/12 15:56:09 UTC

Xdoclet: Why the default size of 24 on VARCHAR's in the new version?

I see in the documentation, and the new build of my repository file from
the 1.2 Release of the OJB Xdoclet module, that if you do not specify a
length for your varchar's, it defaults to a value of 24.

Why was this change necessary? I see that it says because of MySQL that
it now defaults to that, but I am confused as to the ramification for
the rest of us. Up to this point, at least on SQL Server, having no
length specified worked great. And actually, I would prefer not to have
to maintain a length field in my java files, if it is not necessary.

Any idea of what will happen if I leave out the length, it defaults to
24, and my column has data longer than 24? Will it truncate it?

Since this setting was for MySQL only, could we have it be a flag on the
Xdoclet tag that it is a MySql run, and then have it do the default
length, otherwise, don't default to a length?

Thanks

-Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Xdoclet: Why the default size of 24 on VARCHAR's in the new version?

Posted by Thomas Dudziak <to...@first.gmd.de>.
On Thu, 12 Feb 2004, Clute, Andrew wrote:

> I see in the documentation, and the new build of my repository file from
> the 1.2 Release of the OJB Xdoclet module, that if you do not specify a
> length for your varchar's, it defaults to a value of 24.
> 
> Why was this change necessary? I see that it says because of MySQL that
> it now defaults to that, but I am confused as to the ramification for
> the rest of us. Up to this point, at least on SQL Server, having no
> length specified worked great. And actually, I would prefer not to have
> to maintain a length field in my java files, if it is not necessary.
> 
> Any idea of what will happen if I leave out the length, it defaults to
> 24, and my column has data longer than 24? Will it truncate it?
> 
> Since this setting was for MySQL only, could we have it be a flag on the
> Xdoclet tag that it is a MySql run, and then have it do the default
> length, otherwise, don't default to a length?

You're right, I initially added this cosntraint because MySQL complained
about the missing length (there was some other db requiring a length but I
dont't know which one that was ... SapDB ?)
Since I didn't want to have the xdoclet module being dependent on the
database in use, I decided to add a default length for char and varchar so
that the unwary user can simply put in '@ojb.field' and it works
regardless of the database.
Another point is that this somewhat enforces the user to think about the
length of the database (VAR)CHAR field which is never as long as a
java string can be (though an increased default length might be better,
see below).

For these reasons I would like to keep this constraint which leads to two
options

* increase the default length to 254 (the length required by JDBC for
database datatypes that can be used for CHAR/VARCHAR)

* allow to specify an empty length (i.e. @ojb.field length="") which then
overrides the default value thus preventing it from being generated

I might also add a warning for fields where the type should have a length
but there was none specified in the field.

Tom


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org