I've been looking around and around without finding any topics related to my situation.
I'm using:
- Play! framework v2.5.3 in Java
- Hibernate EntityManager v5.1.0.Final
- Hibernate JPA 2.1 API v1.0.0.Final
- PostgreSQL 9.4
Here the route called with AJAX:
PUT /admin/entity/:id
Which is bound to:
controllers.Entity.update(id: Long)
Here how I handle the update request:
@play.db.jpa.Transactional
public Result update(final long id) {
EntityManager em = _jpa.em("default");
DynamicForm form = _formFactory.form().bindFromRequest();
models.Entity entity;
entity = em.find(models.Entity.class, id);
if (entity == null)
return badRequest();
entity.update(em, form);
em.merge(entity);
return ok();
The method update
of Entity
change values of the class attributes which are basically String attributes.
My issue: nothing get updated while still executing this piece of code.
I enable SQL log which only display the SELECT query corresponding to em.find()
method call. Nothing related to an UPDATE query.
I've been using JPA/EntityManager with Play! for others projects (but with lower version of the framework) without facing this kind of problem.
Any idea why nothing get merged ?
I've been able to fix this issue by writing following piece of code inside
models.Entity.update
:em.getTransaction.begin(); Query query = em.createQuery("UPDATE entity SET value = :v WHERE id = :id"); query.setParameter("value", value); query.setParameter("id", id); query.executeUpdate(); em.getTransaction.commit();
But even if this is working, that's not the way how thing should be done... It doesn't make coffee at all!
Edit: this solution do not work anymore....
I really don't know what I'm doing bad, if any body has an idea about this issue, you're help would be much appreciated.