Very weird PreparedStatement in java?

I found a very strange PreparedStatement in the program today to get the error I received. I tracked it and found SQL perplexed. Now I am not a SQL master or PreparedStatements, but this seems very wrong. I should also mention that this works on a colleague's computer, but not mine.

static final String SELECT_UNCOMPLETE_TASKS_FOR_UPGRADE = "SELECT i.employeeid, i.taskid, i.itptaskarchivecd, i.itptaskstartdt, i.itptaskcompletiondt,t.taskobsoletecd, " + "t.taskknowledgetx, t.taskProductid, t.taskrfrncid, t.taskcorecd, t.taskwartimecd, t.parentheaderid, " + "t.taskparentindcd, i.itptaskstatuscd, i.itptaskarchivedt, t.certified " + "FROM itptask i,task t " + "WHERE (i.itptaskcompletiondt is NULL " + "AND i.employeeid = ?1 " + "AND i.taskid = t.taskid " + "AND i.itptaskarchivecd = ?2 " + "AND t.taskproductcd = ?3 " + "AND t.taskobsoletecd = ?4 " + "AND t.taskcorecd = ?5) " + "OR (i.employeeid = ?6 " + "AND i.taskid = t.taskid " + "AND 'T' = t.taskparentindcd " + "AND t.taskproductcd = ?7)"; 

My question is simple, what are the numbers after the placeholder parameters (question marks)? If this is a completely wrong syntax, what would it work in a different workspace / environment? Any help would be greatly appreciated. Thanks.

+6
source share
1 answer

This particular syntax looks specific to the JPA syntax. In jpa you can specify? # To indicate the index of a parameter through a Query object.

 Query myQuery = entityManager.createNativeQuery("select * from my_table where foo = ?1 and bar = ?2"); q.setParameter(1,myFoo); q.setParameter(2,myBar); 
+5
source

Source: https://habr.com/ru/post/971619/


All Articles