lundi 13 juin 2016

Spring Framework JpaRepository returns duplicates of first table row by findAll() method

Here is my JpaRepository

public interface ProcessorRepository extends JpaRepository<Processor, Integer> {

}

Controller

...
@Autowired
ProcessorRepository processorRepository;

@RequestMapping("/getAll")
public String showAllProcessors(Map map){

    List<Processor> processorList = processorRepository.findAll();

    map.put("processors", processorList);
    return "main";
}

main.jsp

....
<select>
<option selected="selected">Choose Processor</option>
<c:forEach var="proc" items="${processors}">
    <option>
            ${proc.processorName}
    </option>
</c:forEach>

This is how Processor mysql table looks like: Processor table

But this is what I get enter image description here

Why it returns duplicates of first row, instead of all different rows?

Aucun commentaire:

Enregistrer un commentaire