@Override
    public TaskRecord findById(long taskId, String owner, boolean includeTrigger) throws Exception {
        StringBuilder find = new StringBuilder(116).append("SELECT t.LOADER,t.MBITS,t.INAME,t.NEXTEXEC,t.RESLT,t.STATES,t.VERSION");
        if (includeTrigger)
            find.append(",t.TRIG");
        find.append(" FROM Task t WHERE t.ID=:i");
        if (owner != null)
            find.append(" AND t.OWNR=:o");

        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(this, tc, "findById", taskId, owner, find);

        List<Object[]> resultList;
        EntityManager em = getPersistenceServiceUnit().createEntityManager();
        try {
            TypedQuery<Object[]> query = em.createQuery(find.toString(), Object[].class);
            query.setParameter("i", taskId);
            if (owner != null)
                query.setParameter("o", owner);
            resultList = query.getResultList();
        } finally {
            em.close();
        }

        TaskRecord taskRecord;
        if (resultList.isEmpty())
            taskRecord = null;
        else {
            Object[] result = resultList.get(0);

            taskRecord = new TaskRecord(false);
            taskRecord.setId(taskId);
            taskRecord.setIdentifierOfClassLoader((String) result[0]);
            taskRecord.setMiscBinaryFlags((Short) result[1]);
            taskRecord.setName((String) result[2]);
            taskRecord.setNextExecutionTime((Long) result[3]);
            taskRecord.setResult((byte[]) result[4]);
            taskRecord.setState((Short) result[5]);
            taskRecord.setVersion((Integer) result[6]);
            if (includeTrigger)
                taskRecord.setTrigger((byte[]) result[7]);
        }

        if (trace && tc.isEntryEnabled())
            Tr.exit(this, tc, "findById", taskRecord);
        return taskRecord;
    }
@ Override public TaskRecord findById ( long taskId , String owner , boolean includeTrigger ) throws Exception { StringBuilder find = new StringBuilder ( 116 ) . append ( "SELECT t.LOADER,t.MBITS,t.INAME,t.NEXTEXEC,t.RESLT,t.STATES,t.VERSION" ) ; if ( includeTrigger ) find . append ( ",t.TRIG" ) ; find . append ( " FROM Task t WHERE t.ID=:i" ) ; if ( owner != null ) find . append ( " AND t.OWNR=:o" ) ; final boolean trace = TraceComponent . isAnyTracingEnabled ( ) ; if ( trace && tc . isEntryEnabled ( ) ) Tr . entry ( this , tc , "findById" , taskId , owner , find ) ; List < Object [ ] > resultList ; EntityManager em = getPersistenceServiceUnit ( ) . createEntityManager ( ) ; try { TypedQuery < Object [ ] > query = em . createQuery ( find . toString ( ) , Object [ ] . class ) ; query . setParameter ( "i" , taskId ) ; if ( owner != null ) query . setParameter ( "o" , owner ) ; resultList = query . getResultList ( ) ; } finally { em . close ( ) ; } TaskRecord taskRecord ; if ( resultList . isEmpty ( ) ) taskRecord = null ; else { Object [ ] result = resultList . get ( 0 ) ; taskRecord = new TaskRecord ( false ) ; taskRecord . setId ( taskId ) ; taskRecord . setIdentifierOfClassLoader ( ( String ) result [ 0 ] ) ; taskRecord . setMiscBinaryFlags ( ( Short ) result [ 1 ] ) ; taskRecord . setName ( ( String ) result [ 2 ] ) ; taskRecord . setNextExecutionTime ( ( Long ) result [ 3 ] ) ; taskRecord . setResult ( ( byte [ ] ) result [ 4 ] ) ; taskRecord . setState ( ( Short ) result [ 5 ] ) ; taskRecord . setVersion ( ( Integer ) result [ 6 ] ) ; if ( includeTrigger ) taskRecord . setTrigger ( ( byte [ ] ) result [ 7 ] ) ; } if ( trace && tc . isEntryEnabled ( ) ) Tr . exit ( this , tc , "findById" , taskRecord ) ; return taskRecord ; }
{@inheritDoc}