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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:21:34+00:00 2026-06-15T10:21:34+00:00

I am using Hibernate over DB2. When I create a NameQuery with the parameter

  • 0

I am using Hibernate over DB2. When I create a NameQuery with the parameter being a List of enum values, getResultList() throws Illegal converation exception.

@NamedQuery(
        name="Deliverable.deliverableFiles",
        query="Select distinct f " +
                "from Deliverable d JOIN d.deliverableFiles f JOIN f.architectures a " +
                "where d.visibility in (:visibilities) and a.architecture in (:architectures) " +
                "and d.hidden = false and releaseType in (:releaseTypes) "
)

Java method:

public static List<DeliverableFile> getDeliverableFiles(EntityManager em, ArrayList<DeliverableVisibility> visibilities,
                                                 ArrayList<DeliverableArchitectureType> architectures,
                                                 ArrayList<DeliverableReleaseType> releaseTypes, int limit) {
    Query deliverableFiles = em.createNamedQuery("Deliverable.deliverableFiles");
    deliverableFiles.setFlushMode(FlushModeType.COMMIT);
    deliverableFiles.setParameter("visibilities", visibilities);
    deliverableFiles.setParameter("architectures", architectures);
    deliverableFiles.setParameter("releaseTypes", releaseTypes);

    List<DeliverableFile> files;

    try {
        files = deliverableFiles.getResultList();   // exceptions is thrown here
    } // end try
    catch (NoResultException nre) {
        files = null;
    } // end catch

    return files;
} // end getDeliveries()

Exception when method gets called:

    ERROR: [jcc][1083][10406][4.2.73] Illegal conversion: can not convert from "byte[]" to "java.lang.String" ERRORCODE=-4474, SQLSTATE=null
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: [jcc][1083][10406][4.2.73] Illegal conversion: can not convert from "byte[]" to "java.lang.String" ERRORCODE=-4474, SQLSTATE=null
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1377)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1300)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:266)
    at **hidden**.jpa.main.Deliverable.getDeliverableFiles(Deliverable.java:68)
    at **hidden**.dbtestbed.DBTestbed.main(DBTestbed.java:165)
Caused by: org.hibernate.exception.GenericJDBCException: [jcc][1083][10406][4.2.73] Illegal conversion: can not convert from "byte[]" to "java.lang.String" ERRORCODE=-4474, SQLSTATE=null
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
    at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
    at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
    at $Proxy40.setBytes(Unknown Source)
    at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$1.doBind(VarbinaryTypeDescriptor.java:57)
    at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:92)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:305)
    at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:300)
    at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:66)
    at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:588)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1736)
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1697)
    at org.hibernate.loader.Loader.doQuery(Loader.java:832)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:293)
    at org.hibernate.loader.Loader.doList(Loader.java:2382)
    at org.hibernate.loader.Loader.doList(Loader.java:2368)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2198)
    at org.hibernate.loader.Loader.list(Loader.java:2193)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
    at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1244)
    at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:257)
    ... 2 more
Caused by: com.ibm.db2.jcc.a.SqlException: [jcc][1083][10406][4.2.73] Illegal conversion: can not convert from "byte[]" to "java.lang.String" ERRORCODE=-4474, SQLSTATE=null
    at com.ibm.db2.jcc.a.cd.a(cd.java:650)
    at com.ibm.db2.jcc.a.cd.a(cd.java:60)
    at com.ibm.db2.jcc.a.cd.a(cd.java:94)
    at com.ibm.db2.jcc.a.gc.a(gc.java:677)
    at com.ibm.db2.jcc.a.vl.a(vl.java:1207)
    at com.ibm.db2.jcc.a.vl.setBytes(vl.java:1174)
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setBytes(NewProxyPreparedStatement.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
    ... 24 more

Any hints or clues or thoughts are greatly appreciated.

  • 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-15T10:21:34+00:00Added an answer on June 15, 2026 at 10:21 am

    Found the problem – it was a simple typo in the NamedQuery. releaseType attribute wasn’t qualified by an alias d. It was supposed to be: d.releaseType in (:releaseTypes). Everything else was correct as far as passing in Enum objects as ArrayList to setParameter().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using hibernate, how can I persist a class with a List<String> field? Consider the
I'm using Hibernate 4. I have this database with Category and CategoryItem tables: CREATE
I'm using Hibernate over mySQL. In mySQL you can put LIKE in queries even
I'm using JPA over Hibernate in my web-app. Here are two entities (only getters
Our application is developed on Java over Play! 1.2.4. We're using JPA over Hibernate
What is the pros and cons using IStatelessSession over ISession in NHibernate?
When using hibernate to retrieve data from Oracle 11g DB using either org.hibernate.dialect.Oracle10gDialect or
when using hibernate with spring, can someone explain how the session unit of work
When using Hibernate 2nd level cache and query cache and not specifying anything inside
I am using Hibernate 3 . Hi , I am attending a session on

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.