0 Replies Latest reply on Aug 16, 2012 4:12 PM by Amasoni

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

      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 ?