Hibernate still issue an SQL Update query while setting value to the entity

Solution Verified - Updated -

Issue

  • While trying to update a record by setting some values into the entity and using merge() method, update query has been executed before executing merge() method.

  • The entity which is used in this code is not detachable entity.

  • Even if merge() statement has been omitted, still update query has been executed.

  • Following is the sample code snippet for the same.

SmSession  smSession  = _em.find(SmSession.class, smSessionId);

//use some setters to update
smSession .setAAA(...)
smSession .setBBB(...)

//execute merge method to update the record
_em.merge(smSession);

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 5.x
    • 6.x
  • JBoss Hibernate
    • 3.x
    • 4.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content