Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Hibernate - Interview Questions and Answers for 'Staleobjectstateexception' - 1 question(s) found - Order By Newest | ||||
| ||||
Ans. This looks like the case for optimistic locking wherein hibernate suspects that the information in table was updated by some other transaction after the entity was loaded by current transaction. One way is to have synchronized entity state and don't detach the entity. Other could be to merge the entity with the table record rather than just directly persisting the entity. | ||||
![]() | ||||
![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
![]() //Double Checked Locking Code public static Singleton createInstance() { if(singleton == null){ synchronized(Singleton.class) { if(singleton == null) { singleton = new Singleton(); } } } return singleton; } //Single checked locking code public static Singleton createInstance() { synchronized(Singleton.class) { if(singleton == null) { singleton = new Singleton(); } } return singleton; } | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||