Navigation Menu

Skip to content

Commit

Permalink
0002216: Replication of rows with NULL in large object column on Post…
Browse files Browse the repository at this point in the history
…greSQL throws exception
  • Loading branch information
chenson42 committed Mar 1, 2015
1 parent 19ec527 commit cd05142
Showing 1 changed file with 9 additions and 10 deletions.
Expand Up @@ -20,33 +20,32 @@
*/
package org.jumpmind.db.platform.postgresql;

import java.sql.Blob;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.jumpmind.db.sql.SymmetricLobHandler;
import org.springframework.jdbc.support.lob.DefaultLobHandler;
import org.springframework.jdbc.support.lob.LobHandler;

public class PostgresLobHandler extends SymmetricLobHandler {

private LobHandler wrappedLobHandler = null;

public PostgresLobHandler() {
super();
DefaultLobHandler wrappedLobHandler = new DefaultLobHandler();
wrappedLobHandler.setWrapAsLob(true);
this.wrappedLobHandler = wrappedLobHandler;
}

public boolean needsAutoCommitFalseForBlob(int jdbcTypeCode, String jdbcTypeName) {
return PostgreSqlDatabasePlatform.isBlobStoredByReference(jdbcTypeName);
}

public byte[] getBlobAsBytes(ResultSet rs, int columnIndex, int jdbcTypeCode, String jdbcTypeName)
throws SQLException {
public byte[] getBlobAsBytes(ResultSet rs, int columnIndex, int jdbcTypeCode,
String jdbcTypeName) throws SQLException {

if (PostgreSqlDatabasePlatform.isBlobStoredByReference(jdbcTypeName)) {
return wrappedLobHandler.getBlobAsBytes(rs, columnIndex);
Blob blob = rs.getBlob(columnIndex);
if (blob != null) {
return blob.getBytes(1, (int) blob.length());
} else {
return null;
}
} else {
return getDefaultHandler().getBlobAsBytes(rs, columnIndex);
}
Expand Down

0 comments on commit cd05142

Please sign in to comment.