xxxxxxxxxx
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.0.2.Final</version>
</dependency>
xxxxxxxxxx
// JPA API
int updatedEntities = entityManager.createQuery(
"update Person p set p.name = :newName where p.name = :oldName")
.setParameter("oldName", oldName)
.setParameter("newName", newName)
.executeUpdate();
xxxxxxxxxx
// Hibernate native API
int updatedEntities = session.createMutationQuery(
"update Person set name = :newName where name = :oldName")
.setParameter("oldName", oldName)
.setParameter("newName", newName)
.executeUpdate();
The connection pooling mechanism ensures that the application does not run out of database connections when it needs one badly. Hibernate is one of the finest ORM frameworks for Java-based applications. When used, it must be tuned for performance optimization.