java.lang.ClassCastException: java.lang.String cannot be cast to org.hibernate.ejb.criteria.Renderable

Hibernate JIRA | Anne Buit | 5 years ago
  1. 0

    [HHH-6747] ClassCastException when rendering SimpleCaseExpression - Hibernate JIRA

    atlassian.net | 11 months ago
    java.lang.ClassCastException: java.lang.String cannot be cast to org.hibernate.ejb.criteria.Renderable
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    We have byte[] field in one of our entity and we want to make query like this. {code} byte[] var = ...; Predicate p = builder.equal(root.get("ourByteField"), var); criteria.where(p); {code} But this code throws exception: [java] Exception in thread "main" java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object; [java] at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:349) [java] at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:364) [java] at org.hibernate.ejb.criteria.CriteriaQueryCompiler$1$1.bind(CriteriaQueryCompiler.java:194) [java] at org.hibernate.ejb.criteria.CriteriaQueryCompiler.compile(CriteriaQueryCompiler.java:247) [java] at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:441) [java] at ru.petrsu.nest.oqlite.test.TestParser.main(TestParser.java:92) [java] Java Result: 1 because class AbstractQueryImpl has code: {code} ... else if ( value.getClass().isArray() ) { final Object[] array = (Object[]) value; ... {code} We offer to change this "if" like this {code} ... else if ( value.getClass().isArray() && value.getClass().equals(Object[].class)) { final Object[] array = (Object[]) value; ... {code} Due to this new condition we get what we want and our criteria works fine. (At least ClassCastExceptio isn't occured). Patch is attached (Also I can do pull request, if needed).

    Hibernate JIRA | 6 years ago | Vyacheslav Dimitrov
    java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object;
  4. 0

    We have byte[] field in one of our entity and we want to make query like this. {code} byte[] var = ...; Predicate p = builder.equal(root.get("ourByteField"), var); criteria.where(p); {code} But this code throws exception: [java] Exception in thread "main" java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object; [java] at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:349) [java] at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:364) [java] at org.hibernate.ejb.criteria.CriteriaQueryCompiler$1$1.bind(CriteriaQueryCompiler.java:194) [java] at org.hibernate.ejb.criteria.CriteriaQueryCompiler.compile(CriteriaQueryCompiler.java:247) [java] at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:441) [java] at ru.petrsu.nest.oqlite.test.TestParser.main(TestParser.java:92) [java] Java Result: 1 because class AbstractQueryImpl has code: {code} ... else if ( value.getClass().isArray() ) { final Object[] array = (Object[]) value; ... {code} We offer to change this "if" like this {code} ... else if ( value.getClass().isArray() && value.getClass().equals(Object[].class)) { final Object[] array = (Object[]) value; ... {code} Due to this new condition we get what we want and our criteria works fine. (At least ClassCastExceptio isn't occured). Patch is attached (Also I can do pull request, if needed).

    Hibernate JIRA | 6 years ago | Vyacheslav Dimitrov
    java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object;

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      java.lang.String cannot be cast to org.hibernate.ejb.criteria.Renderable

      at org.hibernate.ejb.criteria.expression.SimpleCaseExpression.render()
    2. Hibernate EJB
      AbstractEntityManagerImpl.createQuery
      1. org.hibernate.ejb.criteria.expression.SimpleCaseExpression.render(SimpleCaseExpression.java:146)
      2. org.hibernate.ejb.criteria.CriteriaQueryImpl.render(CriteriaQueryImpl.java:346)
      3. org.hibernate.ejb.criteria.CriteriaQueryCompiler.compile(CriteriaQueryCompiler.java:223)
      4. org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:441)
      4 frames