Reputation: 51
I am working on Mvc architecture,I have pojo object i want change primary key please can you help me Primary key is varchar Ex:
Users users=usersDao.load("mark")
Upvotes: 5
Views: 15986
Reputation: 713
as still as I understand you need to try SQL/JDBC directly. And then somehow try to invalidate the entity from hibernate inner state and all caches.
Upvotes: 0
Reputation: 8446
You should never change the value of the primary key. The primary key defines the identity of the object. Hibernate or any other JPA implementation cannot identify the object as the same object if the primary key has been changed. If the primary key is subject to change, you should either choose another primary key or generate a surrogate key.
The workaround is to
Upvotes: 15