0 Replies Latest reply: Aug 16, 2012 11:12 AM by Amasoni RSS

    jpql - multi expressions in select query, java.lang.ClassCastException:

    Amasoni
      Hello, i'm trying to get a Unit object from the query below.
      i am getting javax.ejb.EJBException in this method


      @NamedQuery(name = "getUnitIdUnitName", query = "SELECT u.unitId,u.unitName FROM Unit u "+ "ORDER BY u.unitName")


      public Unit getUnitsComboBox() {
      //get UnitId, UnitName from Units.
      Unit unitIDUnitName =(Unit) ((List<Object[]>)em.createNamedQuery("getUnitIdUnitName").getResultList()).get(0)[0];


      return unitIDUnitName;
      }


      Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to mmis.entity.Unit

      Must i use an iterator ?


      Thanx