ERROR when selecting a simulation

0

I have a subscription problem.

I have a screen that retrieves cycles that are open according to the course of the user and for each cycle of this already has a saved simulation, that is, a relationship.

BEAN:

@PostConstruct

private void init(){
    this.ciclosCurso = CicloDAO.buscaCicloPorCursoDoUsuario(
                codigoCursoUsuario, dataMaxima);
}

The problem I'm facing is the following:

At the time of responding to a cycle, if it has 2 cycles, it only takes the last one: I know where the problem is, I just do not know how to solve it.

Look closely:

No meu dataTable eu tenho: 

                    <p:column headerText="Responder Simulado" style="width: 100px; text-align: center">
                        <p:commandButton id="responderSimulado" icon="ui-icon-check" title="Responder Simulado" update="@this :frmCadastroSimulado:exibePerguntas"
                            actionListener="#{responderSimuladoBean.recuperaSimuladoDeAcordoComCicloSelecionado}">
                            <f:param name="ciclo" value="#{ciclo.codigo}"/>
                        </p:commandButton>
                    </p:column>

In the method that retrievesSimulateCollectiveSelected () in my bean looks like this:

public void recuperaSimuladoDeAcordoComCicloSelecionado() {
        for (Ciclo ciclo : ciclosCurso) {
            this.simulado = this.simuladoDAO.buscaSimuladoPorCiclo(ciclo
                    .getCodigo());
        }

Just to complement:

select s from Simulado s where s.ciclo.codigo = :idCiclo

In short, I retrieve a dummy by the cycle code. The problem is that in the code snippet above it retrieves the dummy I want and then retrieves the other dummy that was found in the PostConstruct, though I did not ask him to respond, ie he finds the dummy with the code I want and then overwrite.

How do I solve it?

    
asked by anonymous 05.11.2015 / 16:06

0 answers