[daisy] [JIRA] Created: (DSY-349) LocalDocumentStrategy doesn't
handle null value properly
pan LI (JIRA)
issues at cocoondev.org
Fri Sep 15 05:18:08 CDT 2006
LocalDocumentStrategy doesn't handle null value properly
---------------------------------------------------------
Key: DSY-349
URL: http://issues.cocoondev.org//browse/DSY-349
Project: Daisy
Type: Bug
Components: Repository
Versions: public - 1.4
Environment: os: Windows XP
db: Derby 10.1
Reporter: pan LI
Priority: Minor
In
LocalDocumentStrategy.storeFields(DocumentImpl document, long documentId, long versionId, Connection conn)
there is:
stmt.setObject(9, dateValue);
stmt.setObject(10, datetimeValue);
stmt.setObject(11, integerValue);
stmt.setObject(12, floatValue);
stmt.setBigDecimal(13, decimalValue);
stmt.setObject(14, booleanValue);
All of the values can be null. As the jdbc doc suggested, we should use stmt.setNull(9, Types.DATE) to set null value to a data field. Some databases don't care, but some databases(in my case, Derby) , this will end in a JDBC exception
I have changed it to :
if (dateValue != null) {
stmt.setObject(9, dateValue);
} else {
stmt.setNull(9, Types.DATE);
}
if (datetimeValue != null) {
stmt.setObject(10, datetimeValue);
} else {
stmt.setNull(10, Types.TIMESTAMP);
}
if (integerValue != null) {
stmt.setObject(11, integerValue);
} else {
stmt.setNull(11, Types.BIGINT);
}
if (floatValue != null) {
stmt.setObject(12, floatValue);
} else {
stmt.setNull(12, Types.FLOAT);
}
if (decimalValue != null) {
stmt.setObject(13, decimalValue);
} else {
stmt.setNull(13, Types.DECIMAL);
}
if (booleanValue != null) {
stmt.setObject(14, booleanValue);
} else {
stmt.setNull(14, Types.BOOLEAN);
}
It works well in my environment.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.cocoondev.org//secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the daisy
mailing list