[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2507) Support for CLOB not working for DB2 when table per concrete class is being used

Faux (JIRA) noreply at atlassian.com
Tue Sep 27 10:39:36 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43729#comment-43729 ] 

Faux commented on HHH-2507:
---------------------------

Under Derby 10.8, this manifests as:
{code}
ERROR 42X61: Types 'INTEGER' and 'VARCHAR' are not UNION compatible.
{code}


Can workaround the problem directly by overloading the dialect:

{code:xml}
<property name="databasePlatform" value="com.example.DerbyDialectHHH2507"/>
{code}

{code:java}
import org.hibernate.dialect.DerbyDialect;

import java.sql.Types;

/** https://hibernate.onjira.com/browse/HHH-2507 */
public class DerbyDialectHHH2507 extends DerbyDialect {
    @Override
    public String getSelectClauseNullString(int sqlType) {
        final int fixedSqlType;
        if (Types.CLOB == sqlType) {
            fixedSqlType = Types.VARCHAR;
        } else {
            fixedSqlType = sqlType;
        }
        return super.getSelectClauseNullString(fixedSqlType);
    }
}
{code}

> Support for CLOB not working for DB2 when table per concrete class is being used
> --------------------------------------------------------------------------------
>
>                 Key: HHH-2507
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2507
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 3.2.2
>            Reporter: breako
>
> Hi,
> This came up in the forums:
> http://forum.hibernate.org/viewtopic.php?p=2344008#2344008
> Sample code: Two Pojos
> @Entity
> public class Person {
>       private int i;
>      @Identity
>       public int getI() {
>              return i;
>       }
>      public void setI(int i){
>             this.i = i;
>      }
> }
> @Entity
> public class Employee extends Person{
>     @Basic(fetch=FetchType.LAZY)
>     @Lob 
>     public String getClobAttr() {
>         return clobAttr;
>     }
>     
>     public void setClobAttr(String clobAttr) {
>         this.clobAttr = clobAttr;
>     }
> }
> Simple test:
> public static void main (String args[]) {
>        Query queryImpl = em.createQuery(" from Person");
>        List list = queryImpl.getResultList();
> }
> This will generate SQL
> select person0_.clobAttr as clobAttr1 from (select nullif(0,0) as clobAttr from TPerson union all select clobAttr from TEmployee) person0_ 
> which chucks the exception:
> DB2 SQL error: SQLCODE: -415, SQLSTATE: 42825, SQLERRMC: null 
> I think the SQL hibernate should generate should be:
> select person0_.clobAttr as clobAttr1 from (select cast(null as CLOB) as clobAttr from TPerson union all select clobAttr from TEmployee) person0_ 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list