D
D
Denis Kuznetsov2019-05-19 20:34:52
Java
Denis Kuznetsov, 2019-05-19 20:34:52

How to use EntityManager?

how to pull out all rows from the database (create a sheet) using entitymanager \ and put one there, if I understand the methods correctly, then

@Autowired
    private EntityManager entityManager;

    public void addUserAccount(ClientOrder clientOrder){
        String sql = "Insert into " +
                tableName + columns +
                "values (" +
                clientOrder.getFirstName() + ", " +
                clientOrder.getLastName() + ", " +
                clientOrder.geteMail() + ", " +
                clientOrder.getPassword() + ")";

        entityManager.createStoredProcedureQuery(sql);
    }

    public ArrayList<ClientOrder> findAllOrders(){
        String sql = "Select * from " + tableName;
        List<ClientOrder> clientOrders = (List<ClientOrder>) entityManager.createQuery(sql);
        return (ArrayList<ClientOrder>) clientOrders;
    }

only practice shows what is wrong

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question