Difficulty to list data in a Spring Boot table

1

I'm working with a simple Spring Boot project using Thymeleaf, this is a product registration, as I have several types of products to register I found interesting to create an entity called product and the other entities that were a product type extend the entity product, that is, it would create a product class and then create a class called pipe and it would extend product, because pipe is a type of product, as you can see below;

Product

@Entity
@Table(name = "produto")
public class Produto {

Cano

@Entity
@Table(name = "cano")
public class Cano extends Produto implements Serializable{

Example;

The product needs to have the attributes that any product has to have, such as name, description and value, so it would create a class called Cano and would only put in that entity's unique attributes and would inherit the attributes of the product class as name, description, and value

In the act of saving everything is fine, as you can see below;

Class controller;

link

Cano registration page

link

I'm now trying to create a pipe search page, and I'm not able to list the database information in an HTML table. Although I have saved as a pipe, the pipe is a type of product, at the time of applying a select in the database I have to do a select in the product table and not in the pipe table, the application fails to create the pipe table, because cano is a type of product, so it's all right.

I am embananando all because it is the first time that I am applying inheritance in my classes in my project.

See my Cano search page

<div class="table-responsive  bw-tabela-simples">
            <table class="table  table-hover">
                <thead>
                    <tr>
                        <th class="table-cervejas-col-foto"></th>
                        <th class="table-cervejas-col-nome">Nome</th>
                        <th class="table-cervejas-col-nome">Descrição</th>
                        <th class="table-cervejas-col-valor">Valor</th>
                        <th class="table-cervejas-col-acoes"></th>
                    </tr>
                </thead>

                <tbody>
                    <tr th:each="cano : ${canos}">
<!--                        <td class="text-center"> -->
<!--                            <img th:src="@{/fotos/temp/{foto}(foto=${cerveja.foto})}" class="img-responsive"/> -->
<!--                        </td> -->
                        <td class="text-center" th:text="${cano.nome}">AA1234</td>
                        <td th:text="${cano.descricao}">Cervej</td>
                        <td class="text-right" th:text="|R$ ${cano.valor}|">R$ 8.00</td>
                        <td class="text-center">
                            <a class="btn  btn-link  btn-xs" title="Editar"> 
                                <i class="glyphicon glyphicon-pencil"></i>
                            </a>
                            <a class="btn  btn-link  btn-xs" title="Excluir">
                                <i class="glyphicon glyphicon-remove"></i>
                            </a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

And insert this line of code into the controller;

@GetMapping
    public ModelAndView pesquisar(){
        ModelAndView mv = new ModelAndView("hidraulico/PesquisaHidraulicos");
        mv.addObject("canos", canos.findAll());
        System.out.println("valor dos canos >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + canos.findAll() );
        return mv;
    }

When I run the page the consoles show me nothing does not return anything, could anyone tell me how I will instantiate the values that are in the database for me to view in the HTML table?

    
asked by anonymous 05.07.2017 / 17:58

0 answers