Hello I need to Migrate My DAO's Class from JDBC to JPA, but what i need is to dont need to change the rs.getInt("NAME_COLUMN")
OR rs.getString("NAME_COLUMN")
the rest of the code PreparedStatement
/ while(rs.next()){....}
its very easy to migrate... i only need to resultset variables...
JDBC CODE
PreparedStatement ps = connection.prepareStatement("SELECT f1, f2 FROM table");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
System.out.println(rs.getInt("f1"));
System.out.println(rs.getString("f2"));
// More than 800 of this...
}
JPA CODE
EntityManager em = PersistenceUtil.getEntityManager();
Query q = em.createNativeQuery("SELECT f1, f2 FROM table");
List<Object[]> results = q.getResultList();
for (Object[] rs : results) {
System.out.println(rs[0]); // need to be rs.getInt("f1")
System.out.println(rs[1]); // need to be rs.getString("f2")
}
I have alot of ResultSet in my project more than 800
I need to a method/Class/something to migrate only the result sets variables (inside for), if I write in rs[0]
I will take a lot of work to re-write all my resulsets in JPA.