Skip to content

Instantly share code, notes, and snippets.

@calvincodes
Last active July 14, 2017 05:53
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/7bc592ed6e891c1d4eac71057d333259 to your computer and use it in GitHub Desktop.
Save calvincodes/7bc592ed6e891c1d4eac71057d333259 to your computer and use it in GitHub Desktop.
@Component
public class ProductDaoImpl implements ProductDao {
@PersistenceContext(type = PersistenceContextType.EXTENDED)
private EntityManager entityManager;
public Product findById(Long id) {
return entityManager.find(Product.class, id);
}
@Transactional
public Product update(Product product, String updatedBrandName) {
product.setBrand(updatedBrandName);
entityManager.persist(product);
return product;
}
public Product update(Long id, String updatedBrandName) {
return this.update(this.findById(id), updatedBrandName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment