Skip to content

Commit

Permalink
0003375 Data Capture Can't Handle Large XMLTYPE Values (#70)
Browse files Browse the repository at this point in the history
Looks good to me.  I like that you followed same pattern as the geometry types.  Thanks for testing and submitting!
  • Loading branch information
albp-rmt authored and erilong committed Mar 15, 2018
1 parent d1eb739 commit c27ccc2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public OracleTriggerTemplate(ISymmetricDialect symmetricDialect) {
clobColumnTemplate = "decode(dbms_lob.getlength(to_clob($(tableAlias).\"$(columnName)\")), null, to_clob(''), '\"'||replace(replace($(tableAlias).\"$(columnName)\",'\\','\\\\'),'\"','\\\"')||'\"')" ;
blobColumnTemplate = "decode(dbms_lob.getlength($(tableAlias).\"$(columnName)\"), null, to_clob(''), '\"'||$(prefixName)_blob2clob($(tableAlias).\"$(columnName)\")||'\"')" ;
booleanColumnTemplate = "decode($(tableAlias).\"$(columnName)\", null, '', '\"'||cast($(tableAlias).\"$(columnName)\" as number("+symmetricDialect.getTemplateNumberPrecisionSpec()+"))||'\"')" ;
xmlColumnTemplate = "decode(dbms_lob.getlength($(tableAlias).\"$(columnName)\".getclobval()), null, to_clob(''), '\"'||replace(replace($(tableAlias).\"$(columnName)\".getclobval(),'\\','\\\\'),'\"','\\\"')||'\"')" ;
triggerConcatCharacter = "||" ;
newTriggerValue = ":new" ;
oldTriggerValue = ":old" ;
Expand Down Expand Up @@ -100,8 +101,8 @@ public OracleTriggerTemplate(ISymmetricDialect symmetricDialect) {
" end if; \n" +
" $(custom_on_insert_text) \n" +
" end; \n");


sqlTemplates.put("updateTriggerTemplate" ,
"create or replace trigger $(triggerName) after update on $(schemaName)$(tableName) \n" +
" for each row begin \n" +
Expand Down Expand Up @@ -165,7 +166,7 @@ public OracleTriggerTemplate(ISymmetricDialect symmetricDialect) {
" end; \n" +
" $(custom_on_update_text) \n" +
" end; \n" );

sqlTemplates.put("deleteTriggerTemplate" ,
"create or replace trigger $(triggerName) after delete on $(schemaName)$(tableName) \n" +
" for each row begin \n" +
Expand All @@ -183,7 +184,7 @@ public OracleTriggerTemplate(ISymmetricDialect symmetricDialect) {
" $(txIdExpression), \n" +
" $(prefixName)_pkg.disable_node_id, \n" +
" $(externalSelect), \n" +
" " + getCreateTimeExpression(symmetricDialect) + " \n" +
" " + getCreateTimeExpression(symmetricDialect) + " \n" +
" ); \n" +
" end if; \n" +
" $(custom_on_delete_text) \n" +
Expand All @@ -192,14 +193,14 @@ public OracleTriggerTemplate(ISymmetricDialect symmetricDialect) {
sqlTemplates.put("initialLoadSqlTemplate" ,
"select $(oracleToClob)$(columns) from $(schemaName)$(tableName) t where $(whereClause) " );
}

protected String getCreateTimeExpression(ISymmetricDialect symmetricDialect) {
String timezone = symmetricDialect.getParameterService().getString(ParameterConstants.DATA_CREATE_TIME_TIMEZONE);
if (StringUtils.isEmpty(timezone)) {
return "CURRENT_TIMESTAMP";
} else {
return String.format("CURRENT_TIMESTAMP AT TIME ZONE '%s'", timezone);
}
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ protected void appendColumnParameter(StringBuilder sql, Column column) {
.append(",");
} else if (isGeometry(column)) {
sql.append("SYM_WKT2GEOM(?)").append(",");
} else if (column.getJdbcTypeName().startsWith("XMLTYPE")) {
sql.append("XMLTYPE(?)").append(",");
} else {
super.appendColumnParameter(sql, column);
}
Expand All @@ -56,6 +58,9 @@ protected void appendColumnEquals(StringBuilder sql, Column column) {
} else if (isGeometry(column)) {
sql.append(quote).append(column.getName()).append(quote).append(" = ")
.append("SYM_WKT2GEOM(?)");
} else if (column.getJdbcTypeName().startsWith("XMLTYPE")) {
sql.append(quote).append(column.getName()).append(quote).append(" = ")
.append("XMLTYPE(?)");
} else {
super.appendColumnEquals(sql, column);
}
Expand All @@ -64,10 +69,9 @@ protected void appendColumnEquals(StringBuilder sql, Column column) {
@Override
protected int getTypeCode(Column column, boolean isDateOverrideToTimestamp) {
int typeCode = super.getTypeCode(column, isDateOverrideToTimestamp);
if (column.getJdbcTypeName().startsWith("XML")) {
typeCode = Types.VARCHAR;
} else if (typeCode == Types.LONGVARCHAR
|| isGeometry(column)) {
if (typeCode == Types.LONGVARCHAR
|| isGeometry(column)
|| column.getJdbcTypeName().startsWith("XMLTYPE")) {
typeCode = Types.CLOB;
}
return typeCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ protected Integer mapUnknownJdbcTypeForColumn(Map<String, Object> values) {
} else if (typeName != null && typeName.startsWith("NCHAR")) {
return Types.CHAR;
} else if (typeName != null && typeName.startsWith("XML")) {
return Types.LONGVARCHAR;
return Types.SQLXML;
} else if (typeName != null && typeName.endsWith("CLOB")) {
return Types.LONGVARCHAR;
} else if (typeName != null && typeName.startsWith("BINARY_FLOAT")) {
Expand Down

0 comments on commit c27ccc2

Please sign in to comment.