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 7565419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:09:02+00:00 2026-05-30T14:09:02+00:00

I am using hibernate framework to be able to use Oracle or Sybase (customer

  • 0

I am using hibernate framework to be able to use Oracle or Sybase (customer choice). But when we switch the connection to Sybase, I have some issues about many-to-one constraint. First of all, Oracle complained for clob fields which have been defined as “text” in hibernate_hbm.xml and I solved this issue with using binary (ClobTypeDescriptor.STREAM_BINDING) in custom type. For Oracle, everything is normal and works perfect. But when I switch the db server to Sybase, I get the following error when trying to save record(s) on table which have foreign key constraint.

Caused by: java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0SL: Unsupported SQL type 2005.
        at com.sybase.jdbc4.jdbc.SybConnection.getAllExceptions(Unknown Source)
        at com.sybase.jdbc4.jdbc.SybStatement.handleSQLE(Unknown Source)
        at com.sybase.jdbc4.jdbc.SybStatement.sendQuery(Unknown Source)
        at com.sybase.jdbc4.jdbc.SybPreparedStatement.sendQuery(Unknown Source)
        at com.sybase.jdbc4.jdbc.SybStatement.executeUpdate(Unknown Source)
        at com.sybase.jdbc4.jdbc.SybPreparedStatement.executeUpdate(Unknown Source)
        at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
        at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
        ... 47 more

Here is the mapping:

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.aykut.test.persistence">

    <class name="classA" table="tableA">
        <id name="tableA_Id" type="long">
            <generator class="native" />
        </id>
        <property name="someDateColumn" type="timestamp" />
        <set name="destinations" table="tableB" cascade="all" lazy="false">
            <key column="tableA_Id" />
            <one-to-many class="classB" />
        </set>
    </class>
    <class name="classB" table="tableB">
        <id name="tableB_Id" type="long">
            <generator class="native" />
        </id>
        <many-to-one name="classA_Data" class="classA" column="tableA_Id" lazy="false" />
        <property name="someInfoColumn" length="64" not-null="true" type="string" />
    </class>
</hibernate-mapping>

I run some tests and if there is no any relation between these two tables, records can be saved normally.

There is some weirdness to me like, if I create tables with ddl manually and give bigint type to id columns and if I don’t use hibernate.hbm2ddl.auto=update property, everything looks normal. Columns created in bigint type and works fine.

if I use hibernate.hbm2ddl.auto=update property, tables created with numeric(19,0) fields for id columns. When this happen, our mapping is thrown above error.

I read some article and I test them but there is no success. Here is my tests.


Adding mapping to not-null=”true” <many-to-one name="classA_Data" class="classA" column="tableA_Id" /> row. FAILED

Adding hibernate.max_fetch_depth = 1 to properties. FAILED.

Adding hibernate.jdbc.use_get_generated_keys=true to properties. FAILED.

These all are happens for Sybase side.

I tested both jconnect 6.0(jdbc3) and 7.0 (jdbc4)

I am using hibernate 3.6.1 final.
Tested with Oracle11gR2 and Sybase 12.0.5 – 15.0.2 – 15.0.3

Any suggestion please?

  • 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-05-30T14:09:03+00:00Added an answer on May 30, 2026 at 2:09 pm

    I have figured out what was the actual problem and solved it. We use custom type for clob field for oracle instances.(This was another solution for oracle.) but when we implemented this custom type, sybase instances started to throw above exception. At the beginning, I thought the problem is constraints but not at all. Problem was; trying to set null to clob fields for sybase clob type.I implemented the overrided nullSafeSet method on our custom type class as if value is null for custom type, convert type to varchar. Also we have had to create new texttypedescriptor for sybase clob fields. Then it works. Here is the solution:

    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import java.sql.Types;
    
    import org.hibernate.HibernateException;
    import org.hibernate.engine.SessionImplementor;
    import org.hibernate.type.AbstractStandardBasicType;
    import org.hibernate.type.descriptor.java.StringTypeDescriptor;
    import org.hibernate.type.descriptor.sql.ClobTypeDescriptor;
    
    public class TextType extends AbstractStandardBasicType<String> {
    
        public static final TextType INSTANCE = new TextType();
    
        public TextType() {
            super((myapp.isOracle?ClobTypeDescriptor.STREAM_BINDING:CustomSybaseTextTypeDescriptor.INSTANCE), StringTypeDescriptor.INSTANCE);
        }
    
        public String getName() {
            return "customtext";
        }
    
        @Override
        public void nullSafeSet(PreparedStatement arg0, Object arg1, int arg2,
                boolean[] arg3, SessionImplementor arg4)
                throws HibernateException, SQLException {
            if(arg1 == null)
                arg0.setNull(arg2,Types.VARCHAR);
            else
                super.nullSafeSet(arg0, arg1, arg2, arg4);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been using Hibernate for years and never have a problem with it, but
I'm have a lot of time using hibernate (JPA) in java, but i recently
I have an app using Spring, JPA (Hibernate) and the Java validation framework (Hibernate
I'm using hibernate validator framework with Spring. A class implementing the Spring Validator validates
I am using hibernate 3.2 with struts 1.2 framework here is the details of
I am using hibernate, spring, struts framework for my application. In my application, each
We are developing a web application using Spring framework and Hibernate ORM. As far
I have this WPF application using NHibernate and lazy data loading. I also use
I have a design question about the use of Hibernate annotations and DAO pattern.
I am using Hibernate 3 as my persistence framework. Below is the sample hbm

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.