db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fox <Thomas....@seitenbau.net>
Subject RE: custom sql types in Torque 4
Date Fri, 04 May 2012 10:56:52 GMT
Greg Monroe wrote:
> Just curious about the specific here.  In the past, the server
> specific JDBC driver would convert from a server specific field into
> a java.sql.Type type.

This has stayed similar. E.G. there is
which decides which Torque(i.e. JDBC) types map to which SQL types for

> So the MySQL JDBC DateTime and Timestamp
> fields would both be mapped to java.sql.Type.TIMESTAMP.

This has changed in Torque 4. See
https://issues.apache.org/jira/browse/TORQUE-11. JDBC TIMESTAMP is now
mapped to MySQL DATETIME.

> This info is available via the MetaData

No. We have the Torque type and the Java type in the ColumnMap but not the
SQL type.

> and that is what Village/Torque used
> to define types needed when populating Torque record objects.

Just to clarify. The Torque type is used, not the SQL type.

> So is this needed because Torque 4 doesn't do something similar?

No this is here to let people override the Torque mapping for a specific

> If this is the case, I'm not sure that just letting people manually map
> to a column type is the solution.  This automatic mapping of server
> specific to standard types via JDBC made it simple for Torque to
> interface with "3rd party schemas".  E.g., if they used Timestamp or
> DateTime, just define the XML column as TIMESTAMP and it worked...
> regardless of if you were using the 3rd party schema defined for

In principle true, but there are people dependent on database-specific
E.g. in MySQL you cannot set a a default of CURRENT_TIMESTAMP for DATETIME
columns, this is only possible for TIMESTAMP columns.
So you can force people to write their own PlatformImpl, but this might be
too complicated for some users.
Or you can aollow them to override the Torque mapping in the schema, which
I am proposing here.
Of course this also has drawbacks, such as you mention, but it can also be
a simple way to change the mapping if a user does not care about database

> I'm thinking that the issue is deeper than just "let the programmer
> patch it for the specific DB". If we do this we lose the ability to
> write Torque code once and run against many DBs when you're "adding
> on" to 3rd party schemas.

There are already features in the schema which are incompatible between
DBs. E.g. there is the BIT data type shich is simply not supported in some
DBs (e.g. Oracle), or to use Varchar sizes > 4000 (not supported in MySQL),
or to use table names longer than 30 chars (not supported in Oracle)....

Just to clarify, personally I know how to create a custom PlatformImpl, so
this is no need of mine, but I thought others may not. Plus it can enable
users to change the mapping for a specific column only, if such a behaviour
is wanted, which you cannot do with a custom PlatformImpl.

I'm just interested to get opinions about the proposed feature, so if you
still think that the problems are larger than the uses of the feature,
please let me know and it'll be less work for me :-).


> -----Original Message-----
> From: Thomas Fox [mailto:Thomas.Fox@seitenbau.net]
> Sent: Wednesday, May 02, 2012 9:02 AM
> To: Apache Torque Developers List
> Subject: custom sql types in Torque 4
> Currently, it is not possible in Torque 4 to use a sql type which is
> not mapped by a Torque type. E.G  the torque type TIMESTAMP is
> mapped to the SQL type DATETIME in mysql, and it is not possible to
> create a column with SQL type TIMESTAMP out of the box.
> Therefore I propose to add an attribute "sqlType" to the column
> Element in whihc the default sql type can be overridden.
> Any objections ?
>     Thomas
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org
> DukeCE Privacy Statement:
> Please be advised that this e-mail and any files transmitted with
> it are confidential communication or may otherwise be privileged or
> confidential and are intended solely for the individual or entity
> to whom they are addressed. If you are not the intended recipient
> you may not rely on the contents of this email or any attachments,
> and we ask that you please not read, copy or retransmit this
> communication, but reply to the sender and destroy the email, its
> contents, and all copies thereof immediately. Any unauthorized
> dissemination, distribution or copying of this communication is
> strictly prohibited.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-dev-help@db.apache.org

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

View raw message