Last active
July 14, 2017 05:53
-
-
Save calvincodes/7bc592ed6e891c1d4eac71057d333259 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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