throw new IllegalStateException("Entity manager is closed.");
}
- // Fake customer instance
- Customer customer = null;
-
// Generate number
String customerNumber = null;
// Default is found
boolean isFound = true;
- // Declare variables
- long part1;
- long part2;
-
// Is the number used?
while (isFound) {
// Both number parts
- part1 = Math.round(Math.random() * 100_000);
- part2 = Math.round(Math.random() * 1_000);
+ long part1 = Math.round(Math.random() * 100_000);
+ long part2 = Math.round(Math.random() * 1_000);
// Generate new number
customerNumber = String.format("%s-%s", part1, part2); //NOI18N
// Try it
try {
// Get instance
- customer = em.getReference(ShopCustomer.class, customerNumber);
+ Customer customer = em.getReference(ShopCustomer.class, customerNumber);
} catch (final EntityNotFoundException ex) {
// Not found
isFound = false;