Hi,
In my application I have to issue queries to read from sequence tables. At the moment I do this as:
Code:
Query query = em.createNativeQuery("SELECT " + SPERSON + ".NEXTVAL FROM DUAL");
Object o = query.getSingleResult();
BigDecimal bigDecimal = (BigDecimal)o;
// bigDecimal is the next value
My questions are:
1. Will the above code just generate a normal SQL statement, I presume it will not use a prepared statement?
2. When does a JPA Query use a prepared statement?
3. How do I adjust the above code to use a prepared statement?
Remember there is no corresponding POJO for the sequence table, so my last question is
4. Is it possible to use prepared statements if there is no corresponding POJO for the query?
Many thanks