Esempio n. 1
0
 public String getDeleteRowSql() {
   if (deleteRowSql == null) {
     switch (getDialect()) {
       case SYBASE:
         deleteRowSql =
             "DELETE FROM "
                 + getTableName()
                 + " WHERE "
                 + config.idColumnName()
                 + " = convert("
                 + config.idColumnType()
                 + ","
                 + "?)";
         break;
       case POSTGRES:
         deleteRowSql =
             "DELETE FROM "
                 + getTableName()
                 + " WHERE "
                 + config.idColumnName()
                 + " = cast(? as "
                 + config.idColumnType()
                 + ")";
         break;
       default:
         deleteRowSql =
             "DELETE FROM " + getTableName() + " WHERE " + config.idColumnName() + " = ?";
         break;
     }
   }
   return deleteRowSql;
 }
Esempio n. 2
0
 public String getSelectRowSql() {
   if (selectRowSql == null) {
     switch (getDialect()) {
       case SYBASE:
         selectRowSql =
             "SELECT "
                 + config.idColumnName()
                 + ", "
                 + config.dataColumnName()
                 + " FROM "
                 + getTableName()
                 + " WHERE "
                 + config.idColumnName()
                 + " = convert("
                 + config.idColumnType()
                 + ","
                 + "?)";
         break;
       case POSTGRES:
         selectRowSql =
             "SELECT "
                 + config.idColumnName()
                 + ", "
                 + config.dataColumnName()
                 + " FROM "
                 + getTableName()
                 + " WHERE "
                 + config.idColumnName()
                 + " = cast(? as "
                 + config.idColumnType()
                 + ")";
         break;
       default:
         selectRowSql =
             "SELECT "
                 + config.idColumnName()
                 + ", "
                 + config.dataColumnName()
                 + " FROM "
                 + getTableName()
                 + " WHERE "
                 + config.idColumnName()
                 + " = ?";
         break;
     }
   }
   return selectRowSql;
 }
Esempio n. 3
0
 public String getUpdateRowSql() {
   if (updateRowSql == null) {
     switch (getDialect()) {
       case SYBASE:
         updateRowSql =
             "UPDATE "
                 + getTableName()
                 + " SET "
                 + config.dataColumnName()
                 + " = ? , "
                 + config.timestampColumnName()
                 + "=? WHERE "
                 + config.idColumnName()
                 + " = convert("
                 + config.idColumnType()
                 + ","
                 + "?)";
         break;
       case POSTGRES:
         updateRowSql =
             "UPDATE "
                 + getTableName()
                 + " SET "
                 + config.dataColumnName()
                 + " = ? , "
                 + config.timestampColumnName()
                 + "=? WHERE "
                 + config.idColumnName()
                 + " = cast(? as "
                 + config.idColumnType()
                 + ")";
         break;
       default:
         updateRowSql =
             "UPDATE "
                 + getTableName()
                 + " SET "
                 + config.dataColumnName()
                 + " = ? , "
                 + config.timestampColumnName()
                 + "=? WHERE "
                 + config.idColumnName()
                 + " = ?";
         break;
     }
   }
   return updateRowSql;
 }
Esempio n. 4
0
 public void createTable(Connection conn) throws PersistenceException {
   // removed CONSTRAINT clause as this causes problems with some databases, like Informix.
   assertMandatoryElementsPresent();
   String createTableDdl =
       "CREATE TABLE "
           + getTableName()
           + "("
           + config.idColumnName()
           + " "
           + config.idColumnType()
           + " NOT NULL, "
           + config.dataColumnName()
           + " "
           + config.dataColumnType()
           + ", "
           + config.timestampColumnName()
           + " "
           + config.timestampColumnType()
           + ", PRIMARY KEY ("
           + config.idColumnName()
           + "))";
   if (trace) {
     log.tracef("Creating table with following DDL: '%s'.", createTableDdl);
   }
   executeUpdateSql(conn, createTableDdl);
 }