For Loop only prints the first record multiple times

0

I have the following problem.

I'm going through a list that contains multiple records, but when I print this information it only shows me the first row multiple times, let's say that a specific user has 49 rows in BD and he prints the first value but 49 times I explain myself?

Something must be wrong in the code:

  

DaoImp

public List<Permisos> obtenerListaPermisos(String username){

List<Permisos> resultado = new ArrayList<Permisos>();
String queryString ="";
queryString ="SELECT * FROM EBSQP.PERMISOS  where USER_NAME='"+username+"' ";
Query consulta =   entityManager.createNativeQuery(queryString,Permisos.class);
resultado = consulta.getResultList();
return resultado;
}
  

Controller

   List<Permisos> permisos = new ArrayList<Permisos>();
        permisos = (List<Permisos>) permisosDao.obtenerListaPermisos(usuarioPaso);

        for(int i =0; i<permisos.size(); i++){
            System.out.println(permisos.get(i).getId_acceso());
          }
  

Mapping Table

package com.c5.application.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="PERMISOS")
public class Permisos implements Serializable {

@Id
@Column(nullable=false)
private String user_name;

@Id
@Column(name="ID_ACCESO")
private BigDecimal idAcceso;


public String getUser_name() {
    return user_name;
}

public void setUser_name(String user_name) {
    this.user_name = user_name;
}

public BigDecimal getIdAcceso() {
    return this.idAcceso;
}

public void setIdAcceso(BigDecimal idAcceso) {
    this.idAcceso = idAcceso;
}

 }

And as I mentioned, it only shows me the first record 49 times.

I'm waiting for comments.

I'm using Spring MVC, Hibernate, Oracle, Eclipse

    
asked by Jairo Ordaz Moreno 01.11.2016 в 17:48
source

0 answers