+ // Default is found
+ boolean isFound = true;
+
+ // Is the number used?
+ while (isFound) {
+ // Both number parts
+ String randString = String.format("%s:%s:%s", Long.toHexString(Math.round(Math.random() * 1_000_000)), em, customer.getCustomerNumber());
+
+ // Generate access key, use SHA512 hashing and BASE64-encoding for strong key generation
+ accessKey = Base64.encodeBase64String(Sha2Crypt.sha512Crypt(randString.getBytes()).getBytes()).substring(0, 100);
+
+ // Try this
+ try {
+ // Get reference
+ orderable = em.getReference(ShopOrder.class, accessKey);
+ } catch (final EntityNotFoundException ex) {
+ // Not found, so abort loop here