I have a Java 8 project. I have a Server class containing:
Long id
string name
string ipAddress
String status
Its an entity to a SQL database. I want to run a criteriaUpdate query that updates my table based on the method outcome. If ‘id’ 1 cant be pinged, how do I change the ‘status’ column without changing all the other ‘id’ columns to.
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaUpdate<ServersDao> cu = cb.createCriteriaUpdate(ServersDao.class);
Root<ServersDao> root = cu.from(ServersDao.class);
cu.set("status", "SERVER_UP");
cu.where(cb.equal(root.get("status", "SERVER_DOWN")));
The problem I have is this changes all my rows in my column to either SERVER_UP or SERVER_DOWN. I need thsi to be based on the relative ‘id’ field, not for all my other id’s.
You need to sign in to view this answers