Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 338897

Summary: @Lob fields don't work on Sybase (includes fix)
Product: z_Archived Reporter: Klaus <klaus.groenbaek>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: jamesssss, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard: submitted_patch

Description Klaus CLA 2011-03-04 03:22:34 EST
Build Identifier: 2.0.0

The Sybase JDBC driver does not support the CLOB and BLOB types (java.sql.Types)
I'm using the Sybase JDBC JConn3.jar from the JConnect 6.0 distribution.

If you annotate a String field in an Entity with the @LOB annotation EclipseLink uses the CLOB type to read/write data from the field, which result in the following exception on Sybase.
java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0SL: Unsupported SQL type 2005.

The fix is simple.
In org.eclipse.persistence.platform.database.SybasePlatform override the getJDBCType() method used for resolving types, in the following way 

public int getJDBCType(Class javaType) {
         if (javaType == ClassConstants.BLOB) {
             return Types.LONGVARBINARY;
         }
        if (javaType == ClassConstants.CLOB) {
            return Types.LONGVARCHAR;
        }
        return super.getJDBCType(javaType);
     }

Reproducible: Always

Steps to Reproduce:
1. Download the JConnect 6 JDBC driver for Sybase
2. Create an Entity with a String field annotated with @Lob
3. try to store the Entity.
Comment 1 Tom Ware CLA 2011-03-18 09:41:28 EDT
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 2 James Sutherland CLA 2011-07-21 11:45:45 EDT
Fixed to use the correct bind type.
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:22:01 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink