ORMUtil : formatSqlDate is hardcoded for Oracle database

Bug #493648 reported by Olivier Chapiteau
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Global Health Observatory
Fix Committed
Undecided
Unassigned

Bug Description

The OrmUtil offer a service to format a date on database : formatSqlDate().
The problem is that ORMUtil is hardcoded to work on an Oracle database, causing a call to an Oracle only sql date format method :

 private static int dbType = SQLUtil.DB_TYPE_ORACLE;

Can we change this harcoded setting to DB_TYPE_MYSQL ?

Revision history for this message
Jiri Dvorak (jiri-dvorak) wrote :

Yes, absolutely, the variable OrmUtil.dbType is static (application-wide) but modifiable (it is *NOT* coded as "static final"); the value DB_TYPE_ORACLE is only as the default. Any application using the ORM toolkit can set it to a database type actually used (currently limited to just Oracle and MySQL).

The standard way to do that is, at application start-up, call the method OrmUtil.setDbType. For example, see the following code snipped in FluID, method BusinessObjectDispatcher.init(), which is called when the Web application is starting up in Tomcat:

 private static synchronized void init() {
  OrmUtil.setDbType(SQLUtil.DB_TYPE_MYSQL);
  initializedFlag = true;
  CommonDTO.setSkipEmptyXmlTagsFlag(true);
  // SessionContext.setReleaseJdbcConnectionEarly(true);
 }

Changed in gho:
milestone: none → data-loader-1.0
Changed in gho:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.