Skip to content

Instantly share code, notes, and snippets.

@calvincodes
Created July 14, 2017 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calvincodes/14c0c6939b1734d70116116a0f4c426b to your computer and use it in GitHub Desktop.
Save calvincodes/14c0c6939b1734d70116116a0f4c426b to your computer and use it in GitHub Desktop.
private void persistTransientBeanWithId() {
// Get a non managed (Transient) product object - Having id set
Product transientProductWithId = ProductMother.getBasicProduct();
dao.update(transientProductWithId, "New Brand Name");
}
private void persistTransientBeanWithoutId() {
// Get a non managed (Transient) product object - And reset ID to null
// This will result in creation of product
Product transientProductWithoutId = ProductMother.getBasicProduct();
transientProductWithoutId.setId(null);
dao.update(transientProductWithoutId, "New Brand Name");
}
private void persistPersistentBean() {
// Will internally get a managed (Persistent) product object
// This will have NO AFFECT on the object at all
dao.update(1l, "New Brand Name");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment