Skip to content

Instantly share code, notes, and snippets.

@cosbor11
Created July 7, 2016 14:15
Show Gist options
  • Save cosbor11/f83ddd129c645101f60cd37bbd72d518 to your computer and use it in GitHub Desktop.
Save cosbor11/f83ddd129c645101f60cd37bbd72d518 to your computer and use it in GitHub Desktop.
Retrive an Account using a long value and verify the generator is no longer used.
// Fetch an account. Notice that the id is now a long rather than an integer.
Account account = (Account)persistenceManager.findById(Account.class, 1l);
assert account.getAccountId() == 1l;
// This example creates a new account and attempts to save it without an identifier.
Account account2 = new Account();
persistenceManager.saveEntity(account2);
// The account ID was not auto incremented.
// This is because we removed the generator from the @Identifier annotation.
assert account2.getAccountId() == 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment