code: @Override
      public long findOrCreate(PartitionRecord record) throws Exception {
          String find = "SELECT p.ID FROM Partition p WHERE p.EXECUTOR=:x AND p.HOSTNAME=:h AND p.LSERVER=:l AND p.USERDIR=:u";
  
          final boolean trace = TraceComponent.isAnyTracingEnabled();
          if (trace && tc.isEntryEnabled())
              Tr.entry(this, tc, "findOrCreate", record, find);
  
          Long result;
          EntityManager em = getPersistenceServiceUnit().createEntityManager();
          try {
              // First look for an existing entry
              TypedQuery<Long> query = em.createQuery(find, Long.class);
              query.setParameter("x", record.getExecutor());
              query.setParameter("h", record.getHostName());
              query.setParameter("l", record.getLibertyServer());
              query.setParameter("u", record.getUserDir());
              List<Long> results = query.getResultList();
              if (results.size() > 0)
                  result = results.get(0);
              else {
                  // If not found, create a new entry
                  Partition partition = new Partition(record);
                  em.persist(partition);
                  em.flush();
                  result = partition.ID;
              }
          } finally {
              em.close();
          }
  
          if (trace && tc.isEntryEnabled())
              Tr.exit(this, tc, "findOrCreate", result);
          return result;
      }
docs: {@inheritDoc}