How I create a native query with multi tables on Quarkus

Viewed 800

I'd liked migrate a native query in springboot to Quarkus, bellow is the repository method:

public MyObject findObject(Long idObject) {
    String query = "SELECT document \n" + 
            "         FROM table_a           cusco,\n" + 
            "              table_b           cust,\n" + 
            "              table_c           accnt,\n" + 
            "              table_d           prdacc,\n" + 
            "              table_e           ctprd_plan,\n" + 
            "              table_f           ctsth_plan,\n" + 
            "              table_g           cntst_plan,\n" + 
            "              table_h           prdct_plan\n" +                
            "        WHERE 1 = 1\n" + 
            "          AND cust.id = cusco.fk_cust_id\n" + 
            ...              
            "          AND cusco.id= ? ";
    
    List<MyObject> list = jdbcTemplate.query(query, new Object[]{idObject}, new MyObjectRowMapper());
    
    if(list != null && !list.isEmpty()){
        return list.get(0);
    }

    return null;
}

Is possible implements this method on Quarkus?

tks!

1 Answers
import javax.persistence.Query;

Query query = em.createNativeQuery("SELECT * FROM table WHERE id = :num");
query.setParameter("num", 1);
List data = query.getResultList();

You can try this

Related