try { IStudentCurricularPlan studentCurricularPlan = new StudentCurricularPlan(); String oqlQuery = "select all from " + StudentCurricularPlan.class.getName(); oqlQuery += " where student.number = $1" ; oqlQuery += " and student.degreeType = $2 "; oqlQuery += " and currentState = $3";  query.create(oqlQuery); query.bind(number); query.bind(degreeType); query.bind(new Integer(StudentCurricularPlanState.ACTIVE));  List result = (List) query.execute(); lockRead(result); if (result.size() != 0) studentCurricularPlan = (IStudentCurricularPlan) result.get(0); return studentCurricularPlan; } catch (QueryException ex) { throw new ExcepcaoPersistencia(ExcepcaoPersistencia.QUERY, ex); } }
Criteria criteria = new Criteria();  criteria.addEqualTo("currentState", StudentCurricularPlanState.ACTIVE_OBJ); criteria.addEqualTo("student.number", number); criteria.addEqualTo("student.degreeType", degreeType);  IStudentCurricularPlan storedStudentCurricularPlan = (IStudentCurricularPlan) queryObject(StudentCurricularPlan.class, criteria);  return storedStudentCurricularPlan;  }
    public IStudentCurricularPlan readActiveByStudentNumberAndDegreeType(Integer number, TipoCurso degreeType) throws ExcepcaoPersistencia {        try {            IStudentCurricularPlan studentCurricularPlan = new StudentCurricularPlan();            String oqlQuery = "select all from " + StudentCurricularPlan.class.getName();            oqlQuery += " where student.number = $1" ;            oqlQuery += " and student.degreeType = $2 ";            oqlQuery += " and currentState = $3";            query.create(oqlQuery);            query.bind(number);            query.bind(degreeType);            query.bind(new Integer(StudentCurricularPlanState.ACTIVE));                        List result = (List) query.execute();            lockRead(result);            if (result.size() != 0)                studentCurricularPlan = (IStudentCurricularPlan) result.get(0);            return studentCurricularPlan;        } catch (QueryException ex) {            throw new ExcepcaoPersistencia(ExcepcaoPersistencia.QUERY, ex);        }    }    