|
In my application I have a table CodeItem as given below CodeItem { Code varchar CodeType varchar Label varchar }
The pk is composite key comprising of column(Code and CodeType) and there is no identity column
DB is SQLServer 2012 /ORM is hibernate 4 Hibernate L2 cache is implemented and it is working fine for all the entities except CodeItem entity.
The CodeItem entity is cached whenever it is accessed for the first time but when the same entity is accessed it is not retrieved from cache but from DB as identity column is not there.
For some restrictions we can not change the table definition.
To overcome the performance issue we have implemented spring cache mechanism, which is working fine.
The problem is that when we retrieve the CodeItem entity from spring cache region, we need to merge it in hibernate session as it is detached entity.
For that we are using session.merge, which will reload the entity from DB.
Is there any way in which I can merge the detached CodeItem entity to hibernate session without making DB query.
I wish to have interfce something like session.merge(entity, reloadFromDBFlag) //where reloadFromDBFlag is boolean
|