Why is this code not working?

  • String id = resourceInstance.getProperty(“id”);
  • 	String provider = resourceInstance.getProperty("provider");
    
  •     OrientVertex configInstance = null;
    

*** // Check if already exists**

  •     Iterator<Vertex> vertices = session.getVertices("controlconfiginstance.id", id).iterator();
    
  •     if (vertices != null && vertices.hasNext()) {
    
  •         configInstance = (OrientVertex) vertices.next();
    
  •     } else {
    
  •         String query = "create vertex controlconfiginstance set id=:id, name=:name, resourceId=:resourceId, " +
    
  •                 "configIdentifier=:configIdentifier, status='UNPROV',complianceStatus = 'UNKNOWN'
    

Still there is a duplicate entries in DB: