I'm using Hibernate within an Eclipse RAP application. I've database tables planned to classes with Hibernate which classes have qualities which are fetched lazily (If these were not fetched lazily i quickly would most likely finish up loading the entire database into memory on my small first query). I don't synchronize database access so you will find multiple Hibernate
Sessions for that customers and allow the DBMS perform the transaction isolation. What this means is different cases of fetched data will fit in with different customers. You will find stuff that if your user changes individuals things, then I must update individuals across multiple customers. Presently I believed about using Hibernate
session.refresh(object) in these instances to refresh the information, but I am unsure how this can impact performance when refreshing multiple objects or maybe it's the proper way to go.
Hope my issue is obvious. Is my approch towards the problem OK or perhaps is it essentially problematic or shall we be held missing something? It is possible to general solution with this type of problem?
I'd appreciate any comments about this.
The overall option would be
- to possess transactions as short as you possibly can
- to link the session lifecycle towards the transaction lifecycle (this is actually the default: the session is closed once the transaction is committed or folded back)
- to make use of positive securing concurrency to prevent two transactions upgrading exactly the same object simultaneously.
If each transaction is extremely short and transaction A updates some object from O to O', then concurrent transaction B is only going to see O until it commits or comes back, and then any other transaction began following a might find O', just because a new session begins using the transaction.