Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8051401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:17:47+00:00 2026-06-05T07:17:47+00:00

Hibernate JPA data type blob doesn’t work with the Sybase image data type. Below

  • 0

Hibernate JPA data type blob doesn’t work with the Sybase image data type. Below is a sample of the data type I’m using. Could someone tell me how to map fileContent to the Sybase image data type?

Sample code

@Column(length=100000)
private byte[] fileContent;

Exception

Caused by: org.hibernate.HibernateException: Wrong column type in DEV_eprs.dbo.pr_file_upload for column file_content. Found: image, expected: varbinary(100000)

When using @Lob, received the following exception when retrieving data.

java.lang.UnsupportedOperationException
The method com.sybase.jdbc3.jdbc.SybResultSet.getBlob(String) is not supported and should not be called.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:17:48+00:00Added an answer on June 5, 2026 at 7:17 am

    I resolved this issue by creating a custom data type, below is the solution. Hope this helps others.

    //Your entity

    @Type(type = "org.company.project.entities.types.BlobType")
    private byte[] fileContent;
    
    public byte[] getFileContent() {
        return fileContent;
    }
    
    public void setFileContent(byte[] fileContent) {
        this.fileContent = fileContent;
    }
    

    //Custom data type

    public class BlobType implements UserType {
    
      public int[] sqlTypes() {
          return new int[] { Types.BLOB };
      }
    
      public Class returnedClass() {
          return Blob.class;
      }
    
      public Object nullSafeGet(ResultSet aResultSet, String[] aColName, Object aObject)
              throws HibernateException, SQLException {
          return getBlobFromBinaryStream(aResultSet, aColName[0]);
      }
    
      private byte[] getBlobFromBinaryStream(ResultSet aResultSet, String aColName)
              throws SQLException {
    
          byte[] theBuff = new byte[2 * 1024];
          InputStream theInStream = aResultSet.getBinaryStream(aColName);
    
          ByteArrayOutputStream theBaos = new ByteArrayOutputStream();
          int n = 0;
          try {
              if (theInStream != null)
              {
                  while (-1 != (n = theInStream.read(theBuff))) {
                      theBaos.write(theBuff, 0, n);
                  }
              }
              theBaos.flush();
          } catch (IOException e) {
              e.printStackTrace();
          }
    
          return theBaos.toByteArray();
      }
    
      public void nullSafeSet(PreparedStatement aStmt, Object aValue, int aIndex)
              throws HibernateException, SQLException {
          aStmt.setBytes(aIndex, (byte[]) aValue);
      }
    
      public boolean equals(Object x, Object y) {
          if ((x == y) ||
                  (x != null && y != null && Arrays.equals(
                          ((byte[]) x),
                          ((byte[]) y)))) {
              return true;
          }
          return false;
      }
    
      public int hashCode(Object aArg) throws HibernateException {
          return aArg.hashCode();
      }
    
      public boolean isMutable() {
          return false;
      }
    
      public Object assemble(Serializable aSerializableObject, Object aObject) throws HibernateException {
          return null;
      }
    
      public Serializable disassemble(Object aObject) throws HibernateException {
          return null;
      }
    
      public Object replace(Object aObject1, Object aObject2, Object aObject3) throws HibernateException {
          return null;
      }
    
      public Object deepCopy(Object aValue) {
          return aValue;
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am working on a RESTful data API using Java, Hibernate, JPA annotations,
I have a JPA/Hibernate data model that I am using the Hibernate hbm2ddl tool
hi i am using JPA hibernate as a persistance framwork all fetc type atribute
I'm currently working on a desktop application using JPA/Hibernate to persist data in a
In a Java application stack with Spring & Hibernate (JPA) in the Data Access
I'm using the Hibernate JPA 2 Metamodel Generator to generate metamodel classes for my
I'm seeing strange behaviour when using PostgreSQL in a Hibernate/JPA environment with a single
We have a setup where we are using an embedded HSQLDB for backing Hibernate/JPA
JPA/Hibernate missing column I am using JPA with Hibernate as the provider. I had
I am using JPA (hibernate), JAX-RS (Jersey) and Jackson. How can I close my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.