In my Java applicaion, I am using hibernate .hbm file to access database; Is this possible to update the primary key \'id\' column in the table; Where the \'id\' column in m
Basically, Hibernate does not allow to update or change the primary key of a database entity.
The reason is the entity data that you fetch from database via some query or .get or .load method goes into persistent context layer.
So from hibernate perspective updating of such persistent entity object means deletion of the older one from database and creation of a new one.
It better to make normal update query like
Query query=HibernateSessionFactory.getSession().createQuery(update table set id=? where id=?);
query.executeUpdate();
HibernateSessionFactory.getSession().beginTransaction().commit();