hibernate many to one performance issue code example
Example 1: Let say your Project Manager tell you that your database requests are consume a lot of memory, you need to do something to improve the performance. How would you do it in hibernate ?
CriteriaBuilder cb = this.em.getCriteriaBuilder();
CriteriaUpdate<Order> update = cb.createCriteriaUpdate(Order.class);
Root e = update.from(Order.class);
update.set("amount", newAmount);
update.where(cb.greaterThanOrEqualTo(e.get("amount"), oldAmount));
this.em.createQuery(update).executeUpdate();
Example 2: Let say your Project Manager tell you that your database requests are consume a lot of memory, you need to do something to improve the performance. How would you do it in hibernate ?
@ManyToMany( mappedBy="authors", fetch=FetchType.LAZY)