Skip to content

Commit d9fd202

Browse files
author
Igor Polevoy
authored
Merge pull request #755 from jfcabral/bugfix/oracle_tests
OracleDialect - override Driver Type Conversion for Dates - Fixes #754
2 parents f2920e4 + 9a64889 commit d9fd202

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

activejdbc/src/main/java/org/javalite/activejdbc/dialects/OracleDialect.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
*/
1616
package org.javalite.activejdbc.dialects;
1717

18-
import java.util.List;
1918
import org.javalite.activejdbc.MetaModel;
19+
import org.javalite.common.Convert;
20+
21+
import java.sql.Timestamp;
22+
import java.util.List;
2023

2124
/**
2225
* @author Igor Polevoy
@@ -77,6 +80,18 @@ public String formSelect(String tableName, String[] columns, String subQuery, Li
7780
return fullQuery.toString();
7881
}
7982

83+
@Override
84+
public Object overrideDriverTypeConversion(MetaModel mm, String attributeName, Object value) {
85+
// Oracle returns java.sql.Timestamp for DATE values
86+
if (value instanceof Timestamp) {
87+
String typeName = mm.getColumnMetadata().get(attributeName).getTypeName();
88+
if ("DATE".equalsIgnoreCase(typeName)) {
89+
return Convert.toSqlDate(value);
90+
}
91+
}
92+
return value;
93+
}
94+
8095
@Override
8196
protected void appendEmptyRow(MetaModel metaModel, StringBuilder query) {
8297
query.append('(').append(metaModel.getIdName()).append(") VALUES (")

0 commit comments

Comments
 (0)