// pm is a product manager object which handles actual database calls
Product product = pm.findProduct( 1 );
List<Product> products = pm.findAllProducts();
products.stream().forEach( System.out::println );
pm.update( product ); // pm object delegates by calling merge on an entity manager object
products = pm.findAllProducts();
products.stream().forEach( System.out::println );
Both println
statements print same number of records, without any change. As there is no state change in product
managed entity,
- Will persistence provider(PP) still send it to the database for update? State for both cases: when second-level cache is and is not used.
- If no, how does PP determine changes?
- If yes, as there's no difference in second output, how do I know for sure that database updated the record? IOW, how can I determine that database had executed an update statement?
EDIT: Added 'derby' tag.